Commit b0aed111 authored by Xiaowu Zhang's avatar Xiaowu Zhang

erp5_travel_expense: manually synchronize all

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