annotate app/view/window/FileUpload.js @ 725:83c571b022f3

Added window for laf file upload and use filtergrid buttons to export or import.
author Raimund Renkert <raimund.renkert@intevation.de>
date Thu, 16 Apr 2015 15:55:32 +0200
parents
children e002234d7da5
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',
83c571b022f3 Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
68 url: '/lada-server/import/laf'
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 console.log(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
73 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
74 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
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 },
83c571b022f3 Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
77
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 uploadSuccess: 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
79 this.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
80 },
83c571b022f3 Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
81
83c571b022f3 Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
82 uploadFailure: 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
83 this.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
84 }
83c571b022f3 Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
85 });

http://lada.wald.intevation.org