8 onTemplateReady : function( template, event, eventData )
10 _w.groups.ti = _t[template];
13 App.DataStore.setData('pricingTypes', [
14 {"value":"Incremental", "label":"Incremental"},
15 {"value":"Fixed", "label":"Fixed"}
17 App.DataStore.setData('priceGuideYesNo', [
18 {"value":"0", "label":"No"},
19 {"value":"1", "label":"Yes"}
23 if (null == App.API.taskContract('gridGroup'))
26 'gridGroup', 'Company', 'Group.List', null,
27 {}, _w.groups.loadGroupGrid, _w.taskContractError
32 _w.groups.loadGroupGrid( null, {}, {} );
34 if (null == App.API.taskContract('addGroup'))
37 'addGroup', 'Company', 'Group.Create', null,
38 {}, function () {}, _w.taskContractError
43 onTemplatePublished : function( template, event, eventData )
45 _w.groups.ti.hydrateParam('name', {
51 _w.groups.ti.hydrateParam('pricingType', {
54 title : 'Pricing Type',
56 dataStoreId : 'pricingTypes'
58 _w.groups.ti.hydrateParam('fixedPricing', {
61 title : 'Fixed Pricing',
64 _w.groups.ti.hydrateParam('priceGuide', {
67 title : 'Price Guide',
69 dataStoreId : 'priceGuideYesNo'
71 _w.groups._setupValidation();
72 $('#btnNew').click(function() {
73 _w.groups.itemId = null;
75 $('#pricingType').selectpicker('val', '');
76 $('#fixedPricing').val('0');
77 $('#priceGuide').selectpicker('val', '');
78 $('label.error').remove();
79 $('#btnSave').html(' Add ');
81 $('#btnNew').prop('disabled', false);
87 _w.groups.ti.hydrate({
89 'gridGroupTitle': 'Manage groups',
90 'gridGroupColumnHeaders': {
91 constructor: 'GridColumnHeader',
94 id: 'gridGroupColumn_name',
98 id: 'gridGroupColumn_pricingType',
102 id: 'gridGroupColumn_fixedPricing',
106 id: 'gridGroupColumn_priceGuide',
111 'gridGroupRowRepeater': {}
116 loadGroupGrid : function( contract, data, options )
119 'gridGroup', data, options,
120 _w.groups._onGroupGridDataReceived, _w.taskExecError
124 _onGroupGridDataReceived : function( response )
126 _w.groups.ti.hydrateParam('gridGroupRowRepeater', {});
128 for (var i = 0; i < response.Data.length; i++)
130 var row = response.Data[i];
136 onClick : function(meta) {
137 _w.groups.itemId = meta.rowId;
138 $('#name').val(meta.items.name);
139 $('#pricingType').selectpicker('val', meta.items.pricingType);
140 $('#fixedPricing').val(meta.items.fixedPricing);
141 $('#priceGuide').selectpicker('val', 'Yes' == meta.items.priceGuide ? '1' : '0');
142 $('#btnSave').html(' Update ');
147 'pricingType' : row.pricingType,
148 'fixedPricing' : row.fixedPricing ? row.fixedPricing : '0',
149 'priceGuide' : row.priceGuide ? 'Yes' : 'No'
153 _w.groups.ti.hydrateParam('gridGroupRowRepeater', {
154 constructor : 'GridDataRow',
159 _setupValidation : function ()
161 $('#frmGroupView').validate({
164 pricingType : "required",
165 fixedPricing : {digits: true, required: true},
166 priceGuide : "required"
169 name : "This field is required.",
170 pricingType : "This field is required.",
171 priceGuide : "This field is required."
173 submitHandler: function( form ) {
174 $('#btnSave').prop('disabled', true);
177 name: $('#name').val(),
178 pricingType: $('#pricingType').val(),
179 fixedPricing: $('#fixedPricing').val(),
180 priceGuide: $('#priceGuide').val()
183 if (null == _w.groups.itemId)
186 'addGroup', data, {},
189 $('#pricingType').selectpicker('val', '');
190 $('#fixedPricing').val('0');
191 $('#priceGuide').selectpicker('val', '');
192 $('label.error').remove();
193 _w.groups.loadGroupGrid( null, {}, {} );
194 $('#btnSave').prop('disabled', false);
195 $('#btnSave').html(' Add ');
202 'updateGroup' + _w.groups.itemId, 'Company', 'Group.Update', null,
203 {id: _w.groups.itemId}, function () {
205 'updateGroup' + _w.groups.itemId, data, {},
208 $('#pricingType').selectpicker('val', '');
209 $('#fixedPricing').val('0');
210 $('#priceGuide').selectpicker('val', '');
211 $('label.error').remove();
212 _w.groups.loadGroupGrid( null, {}, {} );
213 $('#btnSave').prop('disabled', false);
214 $('#btnSave').html(' Add ');
217 }, _w.taskContractError
222 $('#btnSave').prop('disabled', false);