comparison app/view/form/Ortszuordnung.js @ 1021:1df6b6210b42 stammdatengrids

WIP First Version of a New Window/Panel combination to edit Ortszuordnungen and Orte
author Dustin Demuth <dustin@intevation.de>
date Thu, 04 Feb 2016 16:31:46 +0100
parents 75ce503ab296
children 6d33a84979e4
comparison
equal deleted inserted replaced
1014:e9e974d31924 1021:1df6b6210b42
12 Ext.define('Lada.view.form.Ortszuordnung', { 12 Ext.define('Lada.view.form.Ortszuordnung', {
13 extend: 'Ext.form.Panel', 13 extend: 'Ext.form.Panel',
14 alias: 'widget.ortszuordnungform', 14 alias: 'widget.ortszuordnungform',
15 15
16 model: 'Lada.model.Ortszuordnung', 16 model: 'Lada.model.Ortszuordnung',
17 width: '100%', 17
18 requires: [
19 'Lada.view.widget.Verwaltungseinheit',
20 'Lada.view.widget.Staat'
21 ],
22
23 layout: 'fit',
18 margin: 5, 24 margin: 5,
19 border: 0, 25 border: 0,
20 26
21 record: null, 27 record: null,
22 28
23 trackResetOnLoad: true, 29 //trackResetOnLoad: true,
24 30
25 initComponent: function() { 31 initComponent: function() {
26 var i18n = Lada.getApplication().bundle; 32 var i18n = Lada.getApplication().bundle;
27 this.items = [{ 33 this.items = [{
28 xtype: 'fieldset', 34 xtype: 'fieldset',
29 title: i18n.getMsg('ortszuordnung.form.fset.title'), 35 title: i18n.getMsg('ortszuordnung.form.fset.title'),
36 layout: 'fit',
30 items: [{ 37 items: [{
38 layout: 'hbox',
31 border: 0, 39 border: 0,
32 margin: '0, 0, 10, 0', 40 margin: '0, 0, 10, 0',
33 dockedItems: [{ 41 dockedItems: [{
34 xtype: 'toolbar', 42 xtype: 'toolbar',
35 dock: 'bottom', 43 dock: 'bottom',
37 style: { 45 style: {
38 borderBottom: '1px solid #b5b8c8 !important', 46 borderBottom: '1px solid #b5b8c8 !important',
39 borderLeft: '1px solid #b5b8c8 !important', 47 borderLeft: '1px solid #b5b8c8 !important',
40 borderRight: '1px solid #b5b8c8 !important' 48 borderRight: '1px solid #b5b8c8 !important'
41 }, 49 },
42 items: ['->', { 50 items: [{
51 text: i18n.getMsg('ortszuordnung.form.setOrt'),
52 qtip: i18n.getMsg('ortszuordnung.form.setOrt.qtip'),
53 icon: 'resources/img/dialog-ok-apply.png',
54 action: 'setOrt',
55 enableToggle: true,
56 disabled: true
57 }, '->', {
43 text: i18n.getMsg('save'), 58 text: i18n.getMsg('save'),
44 qtip: i18n.getMsg('save.qtip'), 59 qtip: i18n.getMsg('save.qtip'),
45 icon: 'resources/img/dialog-ok-apply.png', 60 icon: 'resources/img/dialog-ok-apply.png',
46 action: 'save', 61 action: 'save',
47 disabled: true 62 disabled: true
52 action: 'discard', 67 action: 'discard',
53 disabled: true 68 disabled: true
54 }] 69 }]
55 }], 70 }],
56 items: [{ 71 items: [{
57 xtype: 'container', 72 layout: 'vbox',
58 layout: { 73 border: 0,
59 type: 'hbox'
60 },
61 flex: 1,
62 items: [{ 74 items: [{
63 xtype: 'tfield', 75 xtype: 'tfield',
64 maxLength: 100, 76 maxLength: 100,
65 name: 'ortszusatztext', 77 name: 'ortszusatztext',
66 fieldLabel: i18n.getMsg('ortszuordnung.form.field.ortszusatztext'), 78 fieldLabel: i18n.getMsg('ortszuordnung.form.field.ortszusatztext'),
67 width: 280,
68 labelWidth: 80
69 }, { 79 }, {
70 xtype: 'tfield', 80 xtype: 'tfield',
71 maxLength: 100, 81 maxLength: 100,
72 name: 'ortszuordnungTyp', 82 name: 'ortszuordnungTyp',
73 fieldLabel: i18n.getMsg('ortszuordnung.form.field.ortszuordnungtyp'), 83 fieldLabel: i18n.getMsg('ortszuordnung.form.field.ortszuordnungtyp'),
74 width: 280, 84 }, {
75 labelWidth: 80 85 xtype: 'textfield',
86 readOnly: true,
87 hidden: true,
88 name: 'ortId'
89 }]
90 }, {
91 layout: 'vbox',
92 border: 0,
93 items: [{
94 xtype: 'displayfield',
95 fieldLabel: i18n.getMsg('orte.gemId'),
96 name: 'gemId'
97 }, {
98 xtype: 'displayfield',
99 fieldLabel: i18n.getMsg('Gemeinde'),
100 name: 'gemeinde'
101 }, {
102 xtype: 'displayfield',
103 fieldLabel: i18n.getMsg('staat'),
104 name: 'staat'
76 }] 105 }]
77 }] 106 }]
78 }] 107 }]
79 }]; 108 }];
80 this.callParent(arguments); 109 this.callParent(arguments);
81 }, 110 },
82 111
83 setRecord: function(record) { 112 setRecord: function(record) {
84 this.getForm().loadRecord(record); 113 this.getForm().loadRecord(record);
114
115 if (! record.get('readonly')) {
116 this.down('[action=setOrt]').enable();
117 this.setReadOnly(false);
118 }
119 else {
120 this.setReadOnly(true);
121 }
122 this.refreshOrt();
123 },
124
125 refreshOrt: function() {
126 var ortId = this.getRecord().get('ortId');
127
128 var orteStore = Ext.StoreManager.get('orte');
129 var ort = orteStore.getById(ortId);
130 var verwStore = Ext.StoreManager.get('verwaltungseinheiten');
131 var verw = verwStore.getById(ort.get('gemId'));
132 var staatStore = Ext.StoreManager.get('staaten');
133 var staat = staatStore.getById(ort.get('staatId'));
134
135 this.getForm().setValues({
136 gemId: ort.get('gemId'),
137 gemeinde: verw.get('bezeichnung'),
138 staat: staat.get('staatIso')
139 });
140 },
141
142 /**
143 * setOrt can be called from a CallbackFunction, ie select from a grid.
144 * it will set the ortId of this record
145 */
146 setOrt: function(row, selRecord, index, opts) {
147
148 console.log('setOrt' + Date.now());
149 var newOrtId = selRecord.get('id');
150 var r = this.getRecord();
151 if (newOrtId) {
152 if (newOrtId != r.get('ortId')) {
153 this.getForm().setValues({ ortId: newOrtId});
154 this.refreshOrt();
155 //set dirty...
156 //this.fireEvent('dirtychange', this.getForm(), true);
157 }
158 }
159 console.log('setOrtEnd' + Date.now());
85 }, 160 },
86 161
87 setMessages: function(errors, warnings) { 162 setMessages: function(errors, warnings) {
88 var key; 163 var key;
89 var element; 164 var element;

http://lada.wald.intevation.org