3 window._w.configview = {
10 onTemplateReady : function( template, event, eventData )
12 _w.configview.ti = _t[template];
13 _w.configview.setConfigViewFormMeta();
14 _w.configview.ti.hydrate(_w.configview.formMeta);
16 // Retrieve initial view data.
17 _w.configview.itemId = 1;
18 _w.configview.ownAccount = (App.userData.id == _w.configview.itemId)
22 'updateConfig:' + _w.configview.itemId, 'AppConfig', 'Config.Update', _w.configview.itemId,
23 {'id':_w.configview.itemId}, $.proxy( _w.configview._onConfigViewDataReceived, this ), _w.taskContractError
27 onTemplatePublished : function( template, event, eventData )
29 if (null != _w.configview.itemData)
31 _w.configview._setupValidation();
35 setConfigViewFormMeta : function( data )
41 _w.configview.formMeta = {
42 'sourceEmailAddress' : {
44 id : 'sourceEmailAddress',
45 title : 'Source email address',
46 value : data.sourceEmailAddress ? data.sourceEmailAddress : '',
49 'sourceMobileAddress' : {
51 id : 'sourceMobileAddress',
52 title : 'Source mobile address',
53 value : data.sourceMobileAddress ? data.sourceMobileAddress : '',
56 'adminEmailAddress' : {
58 id : 'adminEmailAddress',
59 title : 'Administrative email address',
60 value : data.adminEmailAddress ? data.adminEmailAddress : '',
63 'priceGuideOpenDays' : {
65 id : 'priceGuideOpenDays',
67 value : data.priceGuideOpenDays ? data.priceGuideOpenDays : '',
70 'priceGuideCompletionDays' : {
72 id : 'priceGuideCompletionDays',
73 title : 'Completion days',
74 value : data.priceGuideCompletionDays ? data.priceGuideCompletionDays : '',
79 id : 'auctionMaxDays',
80 title : 'Auction max days',
81 value : data.auctionMaxDays ? data.auctionMaxDays : '',
87 _onConfigViewDataReceived : function( response )
89 _w.configview.itemData = response.Data;
90 _w.configview.setConfigViewFormMeta(response.Data);
91 _w.configview.ti.hydrate(_w.configview.formMeta);
92 if (_w.configview.ti.published)
94 _w.configview._setupValidation();
98 _setupValidation : function ()
100 $('#frmConfigView').validate({
102 priceGuideOpenDays: {required: true, minlength: 1, maxlength: 2, digits: true},
103 priceGuideCompletionDays: {required: true, minlength: 1, maxlength: 2, digits: true},
104 auctionMaxDays: {required: true, minlength: 1, maxlength: 2, digits: true},
105 sourceMobileAddress: {required: false, mobile: true},
106 sourceEmailAddress: {required: true, email: true},
107 adminEmailAddress: {required: true, email: true}
110 sourceEmailAddress: {
111 email: "Must be a valid email address."
114 email: "Must be a valid email address."
116 priceGuideOpenDays: {
117 minlength: "Must be 1 to 2 digit.",
118 maxlength: "Must be 1 to 2 digit."
120 priceGuideCompletionDays: {
121 minlength: "Must be 1 to 2 digits.",
122 maxlength: "Must be 1 to 2 digits."
125 minlength: "Must be 1 to 2 digits.",
126 maxlength: "Must be 1 to 2 digits."
129 submitHandler: function( form ) {
130 $('#btnUpdate').prop('disabled', true);
131 var data = _w.configview._prepConfigUpdateData();
133 'updateConfig:' + _w.configview.itemId, data, {},
134 _w.configview._onConfigUpdated, _w.taskExecError
138 $('#btnUpdate').prop('disabled', false);
141 _prepConfigUpdateData : function()
143 var data = {Config:_w.configview.ti.harvest()};
144 if ('' == data.Config.sourceMobileAddress)
146 data.Config.sourceMobileAddress = null;
151 _onConfigUpdated : function( response )
153 window.location.hash = '/systemsettings';