|
5 | 5 | var i18n = xtens.module('i18n').en;
|
6 | 6 | var router = xtens.router;
|
7 | 7 | var Group = xtens.module('group');
|
| 8 | + var AddressInformation = xtens.module("addressinformation"); |
8 | 9 | var GroupsOperator =xtens.module('groupsOperator');
|
9 | 10 | var sexOptions = xtens.module('xtensconstants').SexOptions;
|
10 | 11 | var ModalDialog = xtens.module('xtensbootstrap').Views.ModalDialog;
|
|
33 | 34 |
|
34 | 35 | Operator.Views.Edit = Backbone.View.extend({
|
35 | 36 |
|
| 37 | + tagName: 'div', |
| 38 | + className: 'operator', |
| 39 | + |
36 | 40 | events: {
|
37 | 41 | 'click button.delete': 'deleteOperator',
|
38 | 42 | 'submit .edit-operator-form': 'saveOperator'
|
|
42 | 46 | $('#main').html(this.el);
|
43 | 47 | this.template = JST['views/templates/operator-edit.ejs'];
|
44 | 48 | this.render();
|
| 49 | + |
| 50 | + this.personalAddressView = new AddressInformation.Views.Edit({ |
| 51 | + model: new AddressInformation.Model(this.model.get("addressInformation")) |
| 52 | + }); |
| 53 | + this.$("#address-information-cnt").append(this.personalAddressView.render().el); |
45 | 54 | },
|
46 | 55 |
|
47 | 56 | bindings: {
|
|
108 | 117 | observe: 'email'
|
109 | 118 | },
|
110 | 119 |
|
111 |
| - '#laboratory': { |
112 |
| - observe: 'laboratory' |
113 |
| - }, |
114 |
| - |
115 |
| - '#phone': { |
116 |
| - observe: 'phone' |
117 |
| - }, |
118 |
| - |
119 | 120 | '#login': 'login'
|
120 | 121 |
|
121 | 122 |
|
|
132 | 133 |
|
133 | 134 | saveOperator: function(ev) {
|
134 | 135 | var that = this;
|
| 136 | + var addressInformation = _.clone(this.personalAddressView.model.attributes); |
135 | 137 | if(!that.model.get('id')){
|
136 | 138 | that.model.set('password',$('#password').val());
|
137 | 139 | }
|
138 |
| - that.model.save(null, { |
139 |
| - success: function(operator) { |
140 |
| - if (that.modal) { |
141 |
| - that.modal.hide(); |
142 |
| - } |
143 |
| - var modal = new ModalDialog({ |
144 |
| - title: i18n('ok'), |
145 |
| - body: i18n('operator-correctly-stored-on-server') |
146 |
| - }); |
147 |
| - that.$modal.append(modal.render().el); |
148 |
| - $('.modal-header').addClass('alert-success'); |
149 |
| - modal.show(); |
150 |
| - |
151 |
| - setTimeout(function(){ modal.hide(); }, 1200); |
152 |
| - that.$('.operator-modal').on('hidden.bs.modal', function (e) { |
153 |
| - modal.remove(); |
154 |
| - xtens.router.navigate('operators', {trigger: true}); |
155 |
| - }); |
| 140 | + this.personalAddressView.model.save(null,{ |
| 141 | + success: function(addressInformation) { |
| 142 | + that.model.save({addressInformation:addressInformation.id}, { |
| 143 | + success: function(operator) { |
| 144 | + if (that.modal) { |
| 145 | + that.modal.hide(); |
| 146 | + } |
| 147 | + var modal = new ModalDialog({ |
| 148 | + title: i18n('ok'), |
| 149 | + body: i18n('operator-correctly-stored-on-server') |
| 150 | + }); |
| 151 | + that.$modal.append(modal.render().el); |
| 152 | + $('.modal-header').addClass('alert-success'); |
| 153 | + modal.show(); |
156 | 154 |
|
| 155 | + setTimeout(function(){ modal.hide(); }, 1200); |
| 156 | + that.$('.operator-modal').on('hidden.bs.modal', function (e) { |
| 157 | + modal.remove(); |
| 158 | + xtens.router.navigate('operators', {trigger: true}); |
| 159 | + }); |
| 160 | + }, |
| 161 | + error: function(model, res) { |
| 162 | + xtens.error(res); |
| 163 | + } |
| 164 | + }); |
157 | 165 | },
|
158 | 166 | error: function(model, res) {
|
159 | 167 | xtens.error(res);
|
160 | 168 | }
|
161 | 169 | });
|
162 |
| - |
163 | 170 | return false;
|
164 | 171 | },
|
165 | 172 |
|
|
0 commit comments