Mercurial > lada > lada-client
annotate app/view/window/FileUpload.js @ 807:18697326c862
Less ugly
author | Dustin Demuth <dustin@intevation.de> |
---|---|
date | Fri, 22 May 2015 15:02:22 +0200 |
parents | 66812ad4b720 |
children | 3bc19188fc3a |
rev | line source |
---|---|
725
83c571b022f3
Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
1 /* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz |
83c571b022f3
Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
2 * Software engineering by Intevation GmbH |
83c571b022f3
Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
3 * |
83c571b022f3
Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
4 * This file is Free Software under the GNU GPL (v>=3) |
83c571b022f3
Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
5 * and comes with ABSOLUTELY NO WARRANTY! Check out |
83c571b022f3
Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
6 * the documentation coming with IMIS-Labordaten-Application for details. |
83c571b022f3
Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
7 */ |
83c571b022f3
Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
8 |
83c571b022f3
Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
9 /** |
83c571b022f3
Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
10 */ |
83c571b022f3
Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
11 Ext.define('Lada.view.window.FileUpload', { |
83c571b022f3
Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
12 extend: 'Ext.window.Window', |
83c571b022f3
Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
13 |
83c571b022f3
Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
14 layout: 'hbox', |
83c571b022f3
Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
15 |
83c571b022f3
Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
16 file: null, |
83c571b022f3
Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
17 |
83c571b022f3
Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
18 initComponent: function() { |
83c571b022f3
Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
19 var me = this; |
83c571b022f3
Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
20 this.browseButton = Ext.create('Ext.ux.upload.BrowseButton', { |
83c571b022f3
Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
21 buttonText: 'Durchsuchen...', |
83c571b022f3
Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
22 margin: '3, 3, 3, 3' |
83c571b022f3
Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
23 }); |
83c571b022f3
Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
24 this.fileInput = Ext.create('Ext.form.field.Text', { |
83c571b022f3
Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
25 allowBlank: false, |
83c571b022f3
Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
26 emptyText: 'Wählen Sie eine Datei', |
83c571b022f3
Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
27 hideLabel: true, |
83c571b022f3
Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
28 margin: '3, 3, 3, 3' |
83c571b022f3
Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
29 }); |
83c571b022f3
Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
30 this.items = [ |
83c571b022f3
Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
31 this.fileInput, |
83c571b022f3
Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
32 this.browseButton |
83c571b022f3
Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
33 ]; |
83c571b022f3
Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
34 this.buttons = [{ |
83c571b022f3
Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
35 text: 'Speichern', |
83c571b022f3
Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
36 handler: this.uploadFile |
83c571b022f3
Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
37 }, { |
83c571b022f3
Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
38 text: 'Abbrechen', |
83c571b022f3
Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
39 handler: this.abort |
83c571b022f3
Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
40 }]; |
83c571b022f3
Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
41 this.on('afterrender', function() { |
83c571b022f3
Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
42 this.browseButton.fileInputEl.dom.removeAttribute('multiple', '0'); |
83c571b022f3
Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
43 }, this); |
83c571b022f3
Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
44 this.browseButton.on('fileselected', this.fileSelected, this); |
83c571b022f3
Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
45 this.callParent(arguments); |
83c571b022f3
Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
46 }, |
83c571b022f3
Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
47 |
83c571b022f3
Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
48 abort: function(button) { |
83c571b022f3
Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
49 var win = button.up('window'); |
83c571b022f3
Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
50 win.close(); |
83c571b022f3
Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
51 }, |
83c571b022f3
Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
52 |
83c571b022f3
Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
53 fileSelected: function(input, file) { |
83c571b022f3
Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
54 var item = Ext.create('Ext.ux.upload.Item', { |
83c571b022f3
Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
55 fileApiObject: file[0] |
83c571b022f3
Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
56 }); |
83c571b022f3
Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
57 this.fileInput.setValue(item.getName()); |
83c571b022f3
Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
58 this.file = item; |
83c571b022f3
Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
59 }, |
83c571b022f3
Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
60 |
83c571b022f3
Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
61 uploadFile: function(button) { |
83c571b022f3
Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
62 var win = button.up('window'); |
83c571b022f3
Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
63 var uploader = Ext.create('Ext.ux.upload.uploader.ExtJsUploader', { |
83c571b022f3
Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
64 extraHeaders: { |
83c571b022f3
Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
65 'X-OPENID-PARAMS': Lada.openIDParams |
83c571b022f3
Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
66 }, |
83c571b022f3
Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
67 method: 'POST', |
727
e002234d7da5
Corrected URL for lada-server in export and import
Dustin Demuth <dustin@intevation.de>
parents:
725
diff
changeset
|
68 url: 'lada-server/import/laf' |
725
83c571b022f3
Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
69 }); |
83c571b022f3
Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
70 this.mon(uploader, 'uploadsuccess', win.uploadSuccess, win); |
83c571b022f3
Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
71 this.mon(uploader, 'uploadfailure', win.uploadFailure, win); |
83c571b022f3
Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
72 if (button.up('window').file !== null) { |
83c571b022f3
Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
73 uploader.uploadItem(button.up('window').file); |
83c571b022f3
Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
74 } |
83c571b022f3
Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
75 }, |
83c571b022f3
Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
76 |
730
66812ad4b720
Show the window for importer response messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
727
diff
changeset
|
77 uploadSuccess: function(file, response) { |
725
83c571b022f3
Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
78 this.close(); |
730
66812ad4b720
Show the window for importer response messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
727
diff
changeset
|
79 var win = Ext.create('Lada.view.window.ImportResponse', { |
66812ad4b720
Show the window for importer response messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
727
diff
changeset
|
80 data: response.response.responseText, |
66812ad4b720
Show the window for importer response messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
727
diff
changeset
|
81 message: response.message, |
66812ad4b720
Show the window for importer response messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
727
diff
changeset
|
82 fileName: file.config.fileApiObject.name, |
66812ad4b720
Show the window for importer response messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
727
diff
changeset
|
83 title: 'Importergebnis' |
66812ad4b720
Show the window for importer response messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
727
diff
changeset
|
84 }); |
66812ad4b720
Show the window for importer response messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
727
diff
changeset
|
85 win.show(); |
725
83c571b022f3
Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
86 }, |
83c571b022f3
Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
87 |
730
66812ad4b720
Show the window for importer response messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
727
diff
changeset
|
88 uploadFailure: function(file, response) { |
725
83c571b022f3
Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
89 this.close(); |
730
66812ad4b720
Show the window for importer response messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
727
diff
changeset
|
90 var win = Ext.create('Lada.view.window.ImportResponse', { |
66812ad4b720
Show the window for importer response messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
727
diff
changeset
|
91 data: response.response.responseText, |
66812ad4b720
Show the window for importer response messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
727
diff
changeset
|
92 message: response.message, |
66812ad4b720
Show the window for importer response messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
727
diff
changeset
|
93 fileName: file.config.fileApiObject.name, |
66812ad4b720
Show the window for importer response messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
727
diff
changeset
|
94 title: 'Importergebnis' |
66812ad4b720
Show the window for importer response messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
727
diff
changeset
|
95 }); |
66812ad4b720
Show the window for importer response messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
727
diff
changeset
|
96 win.show(); |
725
83c571b022f3
Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
97 } |
83c571b022f3
Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
98 }); |