comparison 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
comparison
equal deleted inserted replaced
724:876456ce0a01 725:83c571b022f3
1 /* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz
2 * Software engineering by Intevation GmbH
3 *
4 * This file is Free Software under the GNU GPL (v>=3)
5 * and comes with ABSOLUTELY NO WARRANTY! Check out
6 * the documentation coming with IMIS-Labordaten-Application for details.
7 */
8
9 /**
10 */
11 Ext.define('Lada.view.window.FileUpload', {
12 extend: 'Ext.window.Window',
13
14 layout: 'hbox',
15
16 file: null,
17
18 initComponent: function() {
19 var me = this;
20 this.browseButton = Ext.create('Ext.ux.upload.BrowseButton', {
21 buttonText: 'Durchsuchen...',
22 margin: '3, 3, 3, 3'
23 });
24 this.fileInput = Ext.create('Ext.form.field.Text', {
25 allowBlank: false,
26 emptyText: 'Wählen Sie eine Datei',
27 hideLabel: true,
28 margin: '3, 3, 3, 3'
29 });
30 this.items = [
31 this.fileInput,
32 this.browseButton
33 ];
34 this.buttons = [{
35 text: 'Speichern',
36 handler: this.uploadFile
37 }, {
38 text: 'Abbrechen',
39 handler: this.abort
40 }];
41 this.on('afterrender', function() {
42 this.browseButton.fileInputEl.dom.removeAttribute('multiple', '0');
43 }, this);
44 this.browseButton.on('fileselected', this.fileSelected, this);
45 this.callParent(arguments);
46 },
47
48 abort: function(button) {
49 var win = button.up('window');
50 win.close();
51 },
52
53 fileSelected: function(input, file) {
54 var item = Ext.create('Ext.ux.upload.Item', {
55 fileApiObject: file[0]
56 });
57 this.fileInput.setValue(item.getName());
58 this.file = item;
59 },
60
61 uploadFile: function(button) {
62 var win = button.up('window');
63 var uploader = Ext.create('Ext.ux.upload.uploader.ExtJsUploader', {
64 extraHeaders: {
65 'X-OPENID-PARAMS': Lada.openIDParams
66 },
67 method: 'POST',
68 url: '/lada-server/import/laf'
69 });
70 this.mon(uploader, 'uploadsuccess', win.uploadSuccess, win);
71 this.mon(uploader, 'uploadfailure', win.uploadFailure, win);
72 console.log(button.up('window'));
73 if (button.up('window').file !== null) {
74 uploader.uploadItem(button.up('window').file);
75 }
76 },
77
78 uploadSuccess: function() {
79 this.close();
80 },
81
82 uploadFailure: function() {
83 this.close();
84 }
85 });

http://lada.wald.intevation.org