Commit 338a0c56 authored by Xiaowu Zhang's avatar Xiaowu Zhang

erp5_travel_expense: manually synchronize all

parent 3de08e7b
...@@ -9,14 +9,13 @@ ...@@ -9,14 +9,13 @@
gadget_klass gadget_klass
.declareAcquiredMethod('post', 'jio_post') .declareAcquiredMethod('post', 'jio_post')
.declareAcquiredMethod('put', 'jio_put') .declareAcquiredMethod('put', 'jio_put')
.declareAcquiredMethod("repair", "jio_repair")
.declareAcquiredMethod("allDocs", "jio_allDocs") .declareAcquiredMethod("allDocs", "jio_allDocs")
.declareAcquiredMethod("redirect", "redirect") .declareAcquiredMethod("redirect", "redirect")
.declareAcquiredMethod("remove", "jio_remove") .declareAcquiredMethod("remove", "jio_remove")
.declareMethod("render", function (options) { .declareMethod("render", function (options) {
var gadget = this; var gadget = this;
gadget.options = options; gadget.options = options;
if (!options.can_add_discussion) { if (!options.can_add_discussion && !options.doc.transition_comment) {
return; return;
} }
return gadget.allDocs({ return gadget.allDocs({
...@@ -77,9 +76,6 @@ ...@@ -77,9 +76,6 @@
*/ */
return gadget.remove(gadget.options.jio_key); return gadget.remove(gadget.options.jio_key);
}) })
.push(function () {
return gadget.repair();
})
.push(function () { .push(function () {
return gadget.redirect({page: gadget.options.page}); return gadget.redirect({page: gadget.options.page});
}); });
......
...@@ -236,7 +236,7 @@ ...@@ -236,7 +236,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>956.54664.34823.8977</string> </value> <value> <string>956.57258.37000.44407</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -254,7 +254,7 @@ ...@@ -254,7 +254,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1485180096.34</float> <float>1485337559.65</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -116,7 +116,6 @@ ...@@ -116,7 +116,6 @@
.declareAcquiredMethod('jio_remove', 'jio_remove') .declareAcquiredMethod('jio_remove', 'jio_remove')
.declareAcquiredMethod('getSetting', 'getSetting') .declareAcquiredMethod('getSetting', 'getSetting')
.declareAcquiredMethod('setSetting', 'setSetting') .declareAcquiredMethod('setSetting', 'setSetting')
.declareAcquiredMethod("repair", "jio_repair")
.declareAcquiredMethod("getUrlFor", "getUrlFor") .declareAcquiredMethod("getUrlFor", "getUrlFor")
.declareMethod('triggerSubmit', function () { .declareMethod('triggerSubmit', function () {
...@@ -126,7 +125,7 @@ ...@@ -126,7 +125,7 @@
.declareMethod("render", function (options) { .declareMethod("render", function (options) {
var gadget = this, var gadget = this,
sync_checked, sync_checked,
sync_state = getWorkflowState(options.jio_key, options.doc.sync_flag), state = getWorkflowState(options),
geoLocation, geoLocation,
related_mission_class, related_mission_class,
related_mission_url, related_mission_url,
...@@ -168,7 +167,7 @@ ...@@ -168,7 +167,7 @@
}) })
.push (function (url) { .push (function (url) {
related_mission_url = url; related_mission_url = url;
if (sync_state === 'Synced') { if (state.readonly) {
geoLocation= {coords: {latitude: options.doc.latitude, longitude: options.doc.longitude}}; geoLocation= {coords: {latitude: options.doc.latitude, longitude: options.doc.longitude}};
} else { } else {
geoLocation = {coords: {latitude: "", longitude: ""}}; geoLocation = {coords: {latitude: "", longitude: ""}};
...@@ -208,7 +207,6 @@ ...@@ -208,7 +207,6 @@
not_sync_checked = 'checked'; not_sync_checked = 'checked';
} }
ops = { ops = {
state: options.doc.state || sync_state,
preview: options.doc.photo_data, preview: options.doc.photo_data,
quantity: options.doc.quantity, quantity: options.doc.quantity,
date: options.doc.date || new Date().toISOString().slice(0,10), date: options.doc.date || new Date().toISOString().slice(0,10),
...@@ -221,10 +219,13 @@ ...@@ -221,10 +219,13 @@
latitude: geoLocation.coords.latitude || "", latitude: geoLocation.coords.latitude || "",
related_mission_url: related_mission_url || "", related_mission_url: related_mission_url || "",
related_mission_class: related_mission_class, related_mission_class: related_mission_class,
related_mission: related_mission related_mission: related_mission,
not_readonly: !state.readonly
}; };
if (sync_state !== 'Synced') { if (state.sync_state === 'Synced') {
ops.not_readonly = true; ops.state = options.doc.state || state.sync_state;
} else {
ops.state = state.sync_state;
} }
return template(ops); return template(ops);
}) })
...@@ -244,7 +245,7 @@ ...@@ -244,7 +245,7 @@
.push(function () { .push(function () {
return gadget.updateHeader({ return gadget.updateHeader({
title: gadget.options.jio_key + " " + (gadget.options.doc.record_revision || 1), title: gadget.options.jio_key + " " + (gadget.options.doc.record_revision || 1),
save_action: sync_state === 'Synced'? false: true save_action: !state.readonly
}); });
}) })
.push(function () { .push(function () {
...@@ -316,8 +317,8 @@ ...@@ -316,8 +317,8 @@
///////////////////////////////////////// /////////////////////////////////////////
.declareService(function () { .declareService(function () {
var gadget = this, var gadget = this,
state = getWorkflowState(gadget.options.jio_key, gadget.options.doc.sync_flag); state = getWorkflowState(gadget.options);
if (state === 'Synced') { if (state.readonly) {
gadget.props.deferred1.resolve(); gadget.props.deferred1.resolve();
return; return;
} }
...@@ -357,6 +358,7 @@ ...@@ -357,6 +358,7 @@
function () { function () {
return getData(gadget) return getData(gadget)
.push(function (doc) { .push(function (doc) {
var key;
if (doc.sync_flag === '1') { if (doc.sync_flag === '1') {
sync = 1; sync = 1;
} }
...@@ -370,20 +372,12 @@ ...@@ -370,20 +372,12 @@
}) })
.push(function () { .push(function () {
return gadget.props.geoGadget.createGeoLocationRecord(); return gadget.props.geoGadget.createGeoLocationRecord();
}) });
.push(function () { }
return gadget.repair(); })
}) .push(function () {
.push(function () { alertify.success("Saved");
return gadget.redirect({page: 'expense_record_list'}); })
})
.push(function () {
alertify.success("Saved");
});
} else {
alertify.success("Saved");
}
});
} }
) )
}) })
......
...@@ -240,7 +240,7 @@ ...@@ -240,7 +240,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>956.54368.26223.52002</string> </value> <value> <string>956.57356.32253.30464</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -258,7 +258,7 @@ ...@@ -258,7 +258,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1485162384.25</float> <float>1485341787.05</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -354,6 +354,9 @@ ...@@ -354,6 +354,9 @@
return wrapJioCall(this, 'repair', arguments) return wrapJioCall(this, 'repair', arguments)
.push(function () { .push(function () {
return setUserTitle(gadget); return setUserTitle(gadget);
})
.push(function () {
return gadget.setSetting('last_sync_date', new Date().toLocaleString());
}); });
}) })
.declareMethod('allDocs', function () { .declareMethod('allDocs', function () {
......
...@@ -224,7 +224,7 @@ ...@@ -224,7 +224,7 @@
</item> </item>
<item> <item>
<key> <string>actor</string> </key> <key> <string>actor</string> </key>
<value> <string>supercedriclen</string> </value> <value> <string>zope</string> </value>
</item> </item>
<item> <item>
<key> <string>comment</string> </key> <key> <string>comment</string> </key>
...@@ -238,7 +238,7 @@ ...@@ -238,7 +238,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>956.55783.61341.2013</string> </value> <value> <string>956.57376.32743.11895</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -256,7 +256,7 @@ ...@@ -256,7 +256,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1485339651.94</float> <float>1485348028.59</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -76,8 +76,7 @@ ...@@ -76,8 +76,7 @@
.declareAcquiredMethod('jio_remove', 'jio_remove') .declareAcquiredMethod('jio_remove', 'jio_remove')
.declareAcquiredMethod('getSetting', 'getSetting') .declareAcquiredMethod('getSetting', 'getSetting')
.declareAcquiredMethod('setSetting', 'setSetting') .declareAcquiredMethod('setSetting', 'setSetting')
.declareAcquiredMethod("repair", "jio_repair")
.declareMethod('triggerSubmit', function () { .declareMethod('triggerSubmit', function () {
return this.props.element.querySelector('button').click(); return this.props.element.querySelector('button').click();
...@@ -86,7 +85,7 @@ ...@@ -86,7 +85,7 @@
.declareMethod("render", function (options) { .declareMethod("render", function (options) {
var gadget = this, var gadget = this,
sync_checked, sync_checked,
sync_state = getWorkflowState(options.jio_key, options.doc.sync_flag), state = getWorkflowState(options),
not_sync_checked; not_sync_checked;
gadget.options = options; gadget.options = options;
...@@ -104,7 +103,7 @@ ...@@ -104,7 +103,7 @@
not_sync_checked = 'checked'; not_sync_checked = 'checked';
} }
ops = { ops = {
state: options.doc.state || sync_state, state: options.doc.state || state.sync_state,
start_date: options.doc.start_date|| new Date().toISOString().slice(0,10), start_date: options.doc.start_date|| new Date().toISOString().slice(0,10),
stop_date: options.doc.stop_date|| new Date().toISOString().slice(0,10), stop_date: options.doc.stop_date|| new Date().toISOString().slice(0,10),
quantity: options.doc.quantity, quantity: options.doc.quantity,
...@@ -112,17 +111,15 @@ ...@@ -112,17 +111,15 @@
sync_checked: sync_checked, sync_checked: sync_checked,
not_sync_checked: not_sync_checked, not_sync_checked: not_sync_checked,
select_options: select_options, select_options: select_options,
not_readonly: !state.readonly
}; };
if (sync_state !== 'Synced') {
ops.not_readonly = true;
}
return template(ops); return template(ops);
}) })
.push(function (html) { .push(function (html) {
gadget.props.element.innerHTML = html; gadget.props.element.innerHTML = html;
return gadget.updateHeader({ return gadget.updateHeader({
title: "Demande de congé", title: "Demande de congé",
save_action: sync_state === 'Synced'? false: true save_action: !state.readonly
}); });
}) })
.push(function () { .push(function () {
...@@ -270,17 +267,7 @@ ...@@ -270,17 +267,7 @@
return gadget.put(gadget.options.jio_key, doc); return gadget.put(gadget.options.jio_key, doc);
}) })
.push(function () { .push(function () {
if (sync === 1) { alertify.success("Saved");
return gadget.repair()
.push(function () {
return gadget.redirect({page: 'leave_request_record_list'});
})
.push(function () {
alertify.success("Saved");
});
} else {
alertify.success("Saved");
}
}); });
} }
) )
......
...@@ -230,7 +230,7 @@ ...@@ -230,7 +230,7 @@
</item> </item>
<item> <item>
<key> <string>actor</string> </key> <key> <string>actor</string> </key>
<value> <string>supercedriclen</string> </value> <value> <string>zope</string> </value>
</item> </item>
<item> <item>
<key> <string>comment</string> </key> <key> <string>comment</string> </key>
...@@ -244,7 +244,7 @@ ...@@ -244,7 +244,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>956.54639.50122.42052</string> </value> <value> <string>956.57480.16314.62344</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -262,7 +262,7 @@ ...@@ -262,7 +262,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1485178593.24</float> <float>1485349157.61</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -64,8 +64,7 @@ ...@@ -64,8 +64,7 @@
.declareAcquiredMethod('jio_remove', 'jio_remove') .declareAcquiredMethod('jio_remove', 'jio_remove')
.declareAcquiredMethod('getSetting', 'getSetting') .declareAcquiredMethod('getSetting', 'getSetting')
.declareAcquiredMethod('setSetting', 'setSetting') .declareAcquiredMethod('setSetting', 'setSetting')
.declareAcquiredMethod("repair", "jio_repair")
.declareMethod('triggerSubmit', function () { .declareMethod('triggerSubmit', function () {
return this.props.element.querySelector('button').click(); return this.props.element.querySelector('button').click();
...@@ -74,7 +73,7 @@ ...@@ -74,7 +73,7 @@
.declareMethod("render", function (options) { .declareMethod("render", function (options) {
var gadget = this, var gadget = this,
sync_checked, sync_checked,
sync_state = getWorkflowState(options.jio_key, options.doc.sync_flag), state = getWorkflowState(options),
not_sync_checked; not_sync_checked;
gadget.options = options; gadget.options = options;
...@@ -95,17 +94,19 @@ ...@@ -95,17 +94,19 @@
title: options.doc.title, title: options.doc.title,
destination_node_title: options.doc.destination_node_title, destination_node_title: options.doc.destination_node_title,
site: options.doc.site, site: options.doc.site,
state: options.doc.state || sync_state, is_synced: state.sync_state === "Synced",
is_synced: sync_state === "Synced",
start_date: options.doc.start_date|| new Date().toISOString().slice(0,10), start_date: options.doc.start_date|| new Date().toISOString().slice(0,10),
stop_date: options.doc.stop_date|| new Date().toISOString().slice(0,10), stop_date: options.doc.stop_date|| new Date().toISOString().slice(0,10),
quantity: options.doc.quantity, quantity: options.doc.quantity,
comment: options.doc.comment, comment: options.doc.comment,
sync_checked: sync_checked, sync_checked: sync_checked,
not_sync_checked: not_sync_checked, not_sync_checked: not_sync_checked,
not_readonly: !state.readonly
}; };
if (sync_state !== 'Synced') { if (state.sync_state === 'Synced') {
ops.not_readonly = true; ops.state = options.doc.state || state.sync_state;
} else {
ops.state = state.sync_state;
} }
return template(ops); return template(ops);
}) })
...@@ -125,7 +126,7 @@ ...@@ -125,7 +126,7 @@
.push(function () { .push(function () {
return gadget.updateHeader({ return gadget.updateHeader({
title: gadget.options.jio_key + " " + (gadget.options.doc.record_revision || 1), title: gadget.options.jio_key + " " + (gadget.options.doc.record_revision || 1),
save_action: sync_state === 'Synced'? false: true save_action: !state.readonly
}); });
}) })
.push(function () { .push(function () {
...@@ -275,17 +276,7 @@ ...@@ -275,17 +276,7 @@
return gadget.put(gadget.options.jio_key, doc); return gadget.put(gadget.options.jio_key, doc);
}) })
.push(function () { .push(function () {
if (sync === 1) { alertify.success("Saved");
return gadget.repair()
.push(function () {
return gadget.redirect({page: 'travel_request_record_list'});
})
.push(function () {
alertify.success("Saved");
});
} else {
alertify.success("Saved");
}
}); });
} }
) )
......
...@@ -230,7 +230,7 @@ ...@@ -230,7 +230,7 @@
</item> </item>
<item> <item>
<key> <string>actor</string> </key> <key> <string>actor</string> </key>
<value> <string>supercedriclen</string> </value> <value> <string>zope</string> </value>
</item> </item>
<item> <item>
<key> <string>comment</string> </key> <key> <string>comment</string> </key>
...@@ -244,7 +244,7 @@ ...@@ -244,7 +244,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>956.44329.14852.21316</string> </value> <value> <string>956.57361.9593.1092</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -262,7 +262,7 @@ ...@@ -262,7 +262,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1484576818.21</float> <float>1485341897.03</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
<form class="synchro-form view-web-page-form"> <form class="synchro-form view-web-page-form">
<button type="submit" data-i18n="Send & Receive" data-theme="c" class=" ui-btn ui-btn-c ui-shadow ui-corner-all">Send & Receive</button> <button type="submit" data-i18n="Send & Receive" data-theme="c" class=" ui-btn ui-btn-c ui-shadow ui-corner-all">Send & Receive</button>
<span>Last Synchronization Date:</span> <span>Last Synchronization Date:</span>
<span class="last_sync_date"></span> <span class="last_sync_date" style='color: red;'></span>
</form> </form>
</div> </div>
</div> </div>
......
...@@ -242,7 +242,7 @@ ...@@ -242,7 +242,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>956.54718.44080.11008</string> </value> <value> <string>956.54794.17747.54920</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -260,7 +260,7 @@ ...@@ -260,7 +260,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1485187816.2</float> <float>1485342857.58</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -34,10 +34,8 @@ ...@@ -34,10 +34,8 @@
.declareAcquiredMethod("getUrlFor", "getUrlFor") .declareAcquiredMethod("getUrlFor", "getUrlFor")
.declareAcquiredMethod("updateHeader", "updateHeader") .declareAcquiredMethod("updateHeader", "updateHeader")
.declareAcquiredMethod('getSetting', 'getSetting') .declareAcquiredMethod('getSetting', 'getSetting')
.declareAcquiredMethod('setSetting', 'setSetting')
.declareAcquiredMethod("jio_allDocs", "jio_allDocs") .declareAcquiredMethod("jio_allDocs", "jio_allDocs")
.declareAcquiredMethod("repair", "jio_repair") .declareAcquiredMethod("redirect", "redirect")
.declareAcquiredMethod("reload", "reload")
.allowPublicAcquisition("jio_allDocs", function (param_list) { .allowPublicAcquisition("jio_allDocs", function (param_list) {
var gadget = this; var gadget = this;
return this.jio_allDocs.apply(this, param_list) return this.jio_allDocs.apply(this, param_list)
...@@ -151,13 +149,10 @@ ...@@ -151,13 +149,10 @@
false, false,
function () { function () {
gadget.props.element.querySelector("button").disabled = true; gadget.props.element.querySelector("button").disabled = true;
return gadget.repair() return gadget.redirect({
.push(function () { page: 'sync',
return gadget.setSetting('last_sync_date', new Date().toLocaleString()); auto_repair: true
}) });
.push(function () {
return gadget.reload();
});
}); });
}); });
}); });
......
...@@ -270,7 +270,7 @@ ...@@ -270,7 +270,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>956.54730.11019.41386</string> </value> <value> <string>956.57372.34651.59340</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -288,7 +288,7 @@ ...@@ -288,7 +288,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1485187819.16</float> <float>1485342563.92</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -44,7 +44,7 @@ ...@@ -44,7 +44,7 @@
<li><a href="#page=localisation" data-i18n="localisation">localisation</a></li> <li><a href="#page=localisation" data-i18n="localisation">localisation</a></li>
<li><a href="#page=expense_report" data-i18n="Reports">Reports</a></li> <li><a href="#page=expense_report" data-i18n="Reports">Reports</a></li>
<!-- li><a href="#page=jio_configurator" data-i18n="Storage Configuration">Storage Configuration</a></li --> <!-- li><a href="#page=jio_configurator" data-i18n="Storage Configuration">Storage Configuration</a></li -->
<li><a href="#page=sync" data-i18n="Synchronization">Synchronization</a></li> <li><a href="#page=sync" data-i18n="Synchronize">Synchronize</a></li>
</ul> </ul>
</div> </div>
</script> </script>
......
...@@ -269,7 +269,7 @@ ...@@ -269,7 +269,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>956.47536.31130.48230</string> </value> <value> <string>956.54637.11779.49271</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -287,7 +287,7 @@ ...@@ -287,7 +287,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1485178390.73</float> <float>1485342891.3</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -3,16 +3,21 @@ ...@@ -3,16 +3,21 @@
(function (window, RSVP) { (function (window, RSVP) {
"use strict"; "use strict";
window.getWorkflowState = function (id, sync_flag) { window.getWorkflowState = function (options) {
var sync_state; var sync_state,
if(id.indexOf("_module/") > 0){ readonly = false;
if(options.jio_key.indexOf("_module/") > 0){
sync_state = "Synced"; sync_state = "Synced";
}else if(sync_flag){ readonly = true;
}else if(options.doc.sync_flag){
sync_state = "Not Synced"; sync_state = "Not Synced";
if (options.doc.state) {
readonly = true;
}
}else{ }else{
sync_state = "Not Ready To Sync"; sync_state = "Not Ready To Sync";
} }
return sync_state; return {sync_state: sync_state, readonly: readonly};
}; };
window.geoLocationPromise = function() { window.geoLocationPromise = function() {
......
...@@ -234,7 +234,7 @@ ...@@ -234,7 +234,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>956.45945.18260.25463</string> </value> <value> <string>956.57355.19823.14643</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -252,7 +252,7 @@ ...@@ -252,7 +252,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1484840353.8</float> <float>1485347131.83</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment