Commit dea68b69 authored by Xiaowu Zhang's avatar Xiaowu Zhang

erp5_travel_expense: improve query

1.use query factory instead of manually query
2.don't get all related object, use modification date to filter
3.synchronize only related service
parent 98ec36e0
......@@ -109,7 +109,7 @@
doc = {
parent_relative_url: "expense_sheet_module",
portal_type: "Expense Sheet",
modification_date: new Date().toISOString()
modification_date: new Date().toISOString().slice(0, 10).replace(/-/g, "/")
};
for (i = 0; i < submit_event.target.length; i += 1) {
if ((form[i].type == "radio") && !form[i].checked){
......
......@@ -250,7 +250,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>989.27549.43950.31078</string> </value>
<value> <string>994.55194.7094.63129</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -268,7 +268,7 @@
</tuple>
<state>
<tuple>
<float>1613394000.22</float>
<float>1631870322.62</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -37,7 +37,7 @@
visible_in_html5_app_flag: 1,
record_revision: (gadget.options.doc.record_revision || 1),
photo_data: gadget.options.doc.photo_data || "",
modification_date: new Date().toISOString()
modification_date: new Date().toISOString().slice(0, 10).replace(/-/g, "/")
};
for (i = 0; i < form.length; i += 1) {
// XXX Should check input type instead
......
......@@ -249,7 +249,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>989.27549.43950.31078</string> </value>
<value> <string>994.55211.54129.37256</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -267,7 +267,7 @@
</tuple>
<state>
<tuple>
<float>1613394030.76</float>
<float>1631870156.36</float>
<string>UTC</string>
</tuple>
</state>
......
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width" />
<title>Jio Gadget</title>
<link rel="stylesheet" type="text/css" href="alertify.css" />
<!-- renderjs -->
<script src="rsvp.js" type="text/javascript"></script>
<script src="renderjs.js" type="text/javascript"></script>
<script src="jiodev.js" type="text/javascript"></script>
<script src="alertify.js" type="text/javascript"></script>
<!-- custom script -->
<script src="gadget_hr_jio.js" type="text/javascript"></script>
</head>
<body>
</body>
</html>
\ No newline at end of file
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Web Page" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_Access_contents_information_Permission</string> </key>
<value>
<tuple>
<string>Anonymous</string>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Auditor</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Add_portal_content_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Change_local_roles_Permission</string> </key>
<value>
<tuple>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Modify_portal_content_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_View_Permission</string> </key>
<value>
<tuple>
<string>Anonymous</string>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Auditor</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>contributor/person_module/2</string>
</tuple>
</value>
</item>
<item>
<key> <string>content_md5</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>text/html</string> </value>
</item>
<item>
<key> <string>default_reference</string> </key>
<value> <string>gadget_hr_jio.html</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string>Jio access</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>gadget_hr_gadget_html</string> </value>
</item>
<item>
<key> <string>language</string> </key>
<value> <string>en</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Web Page</string> </value>
</item>
<item>
<key> <string>short_title</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Jio Gadget for HR</string> </value>
</item>
<item>
<key> <string>version</string> </key>
<value> <string>001</string> </value>
</item>
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary>
<item>
<key> <string>document_publication_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
<item>
<key> <string>edit_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value>
</item>
<item>
<key> <string>processing_status_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAU=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>publish_alive</string> </value>
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>zope</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>error_message</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>time</string> </key>
<value>
<object>
<klass>
<global name="DateTime" module="DateTime.DateTime"/>
</klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>1479221737.93</float>
<string>UTC</string>
</tuple>
</state>
</object>
</value>
</item>
<item>
<key> <string>validation_state</string> </key>
<value> <string>published_alive</string> </value>
</item>
</dictionary>
</list>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>edit</string> </value>
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>supercedriclen</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>error_message</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>955.64152.22474.31095</string> </value>
</item>
<item>
<key> <string>state</string> </key>
<value> <string>current</string> </value>
</item>
<item>
<key> <string>time</string> </key>
<value>
<object>
<klass>
<global name="DateTime" module="DateTime.DateTime"/>
</klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>1481817158.93</float>
<string>UTC</string>
</tuple>
</state>
</object>
</value>
</item>
</dictionary>
</list>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="5" aka="AAAAAAAAAAU=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>detect_converted_file</string> </value>
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>zope</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>error_message</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>external_processing_state</string> </key>
<value> <string>converted</string> </value>
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>0.0.0.0</string> </value>
</item>
<item>
<key> <string>time</string> </key>
<value>
<object>
<klass>
<global name="DateTime" module="DateTime.DateTime"/>
</klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>1479221700.82</float>
<string>UTC</string>
</tuple>
</state>
</object>
</value>
</item>
</dictionary>
</list>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -59,7 +59,7 @@
latitude: gadget.geoLocation.coords.latitude,
source_title: gadget.author,
simulation_state: 'draft',
creation_date:new Date().toISOString().slice(0, 10)
modification_date:new Date().toISOString().slice(0, 10).replace(/-/g, "/")
});
});
});
......
......@@ -236,7 +236,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>956.50385.17297.63180</string> </value>
<value> <string>994.55194.7094.63129</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -254,7 +254,7 @@
</tuple>
<state>
<tuple>
<float>1485167188.03</float>
<float>1631882043.11</float>
<string>UTC</string>
</tuple>
</state>
......
/*global window, rJS, RSVP, jIO, alertify, UriTemplate, indexedDB*/
/*jslint indent: 2, nomen: true */
(function (window, rJS, RSVP, jIO, UriTemplate, alertify, indexedDB) {
"use strict";
// xxxxxxxxxxxxxxxxx overwrite
/*
function openIndexedDB(jio_storage) {
var db_name = jio_storage._database_name;
function resolver(resolve, reject) {
// Open DB //
var request = indexedDB.open(db_name);
request.onerror = function (error) {
if (request.result) {
request.result.close();
}
reject(error);
};
request.onabort = function () {
request.result.close();
reject("Aborting connection to: " + db_name);
};
request.ontimeout = function () {
request.result.close();
reject("Connection to: " + db_name + " timeout");
};
request.onblocked = function () {
request.result.close();
reject("Connection to: " + db_name + " was blocked");
};
// Create DB if necessary //
request.onupgradeneeded = function () {
return;
};
request.onversionchange = function () {
request.result.close();
reject(db_name + " was upgraded");
};
request.onsuccess = function () {
resolve(request.result);
};
}
// XXX Canceller???
return new RSVP.Queue()
.push(function () {
return new RSVP.Promise(resolver);
});
}
function openTransaction(db, stores, flag, autoclosedb) {
var tx = db.transaction(stores, flag);
if (autoclosedb !== false) {
tx.oncomplete = function () {
db.close();
};
}
tx.onabort = function () {
db.close();
};
return tx;
}
function handleRequest(request) {
function resolver(resolve, reject) {
request.onerror = reject;
request.onsuccess = function () {
resolve(request.result);
};
}
return new RSVP.Promise(resolver);
}
jIO.__storage_types.indexeddb.prototype.remove = function (id) {
return openIndexedDB(this)
.push(function (db) {
var transaction = openTransaction(db, ["metadata"], "readwrite");
return handleRequest(transaction
.objectStore("metadata")["delete"](id));
});
};*/
function endsWith(str, suffix) {
return str.indexOf(suffix, str.length - suffix.length) !== -1;
}
function hashParams() {
var hash = window.location.toString().split('#')[1],
split,
query = "",
subhashes,
subhash,
keyvalue,
index,
key,
tmp,
args = {};
if (hash !== undefined) {
split = hash.split('?');
query = split[0] || "";
}
subhashes = query.split('&');
for (index in subhashes) {
if (subhashes.hasOwnProperty(index)) {
subhash = subhashes[index];
if (subhash !== '') {
keyvalue = subhash.split('=');
if (keyvalue.length === 2) {
key = decodeURIComponent(keyvalue[0]);
tmp = decodeURIComponent(keyvalue[1]);
if (tmp && (endsWith(key, ":json"))) {
tmp = JSON.parse(tmp);
}
args[key] = tmp;
}
}
}
}
return args;
}
function handleHTTPError(gadget, error, method_name) {
var regexp = /^X-Delegate uri="(http[s]*:\/\/[\/\-\[\]{}()*+:?.,\\\^$|#\s\w%]+)"$/,
login_page;
if ((error.target !== undefined) && (error.target.status === 401)) {
login_page = error.target.getResponseHeader('WWW-Authenticate');
// Only connect to https to login
var regexp = /^X-Delegate uri="(http[s]*:\/\/[\/\-\[\]{}()*+:?.,\\\^$|#\s\w%]+)"$/
var auth_page = error.target.getResponseHeader('WWW-Authenticate'),
site;
if (regexp.test(auth_page)) {
site = UriTemplate.parse(
regexp.exec(auth_page)[1]
).expand({
came_from: window.location.href + "#{&n.me}",
cors_origin: window.location.origin,
});
}
if (site) {
return gadget.redirect({ toExternal: true, url: site});
}
}
if ((error.target !== undefined) && (error.target.status === 0)) {
alertify.error("you are offline");
window.setTimeout(function () {
if (method_name === 'repair') {
alertify.error("synchronisation failed");
}
if (method_name === 'getAttachment') {
alertify.error("please try again when online");
}
}, 2000);
return;
}
throw error;
}
function wrapJioCall(gadget, method_name, argument_list, default_storage) {
var storage = default_storage || gadget.state_parameter_dict.jio_storage;
/*if (!gadget.state_parameter_dict.authenticated) {
// Access ERP5 to get information about the login page
return gadget.state_parameter_dict.jio_storage.__storage._remote_sub_storage.getAttachment(
'acl_users',
'links',
{format: 'json'}
)
.push(function () {
gadget.state_parameter_dict.authenticated = true;
return wrapJioCall(gadget, method_name, argument_list);
}, function (error) {
return handleHTTPError(gadget, error);
});
}*/
return storage[method_name].apply(storage, argument_list)
.push(undefined, function (error) {
return handleHTTPError(gadget, error, method_name);
});
}
function setUserTitle(gadget, no_auto_resync) {
// Get user information
return;
return gadget.getSetting('user_title')
.push(function (user_title) {
if (!user_title) {
// Force synchro when user login
return wrapJioCall(gadget, 'repair');
}
})
.push(function () {
return wrapJioCall(gadget, 'get', [gadget.state_parameter_dict.me]);
})
.push(function (person) {
if (person) {
return gadget.setSetting('user_title', person.first_name + " " + person.last_name);
} else {
return gadget.setSetting('user_title', '');
}
}, function (error) {
if ((error instanceof jIO.util.jIOError) && (error.status_code === 404)) {
if (no_auto_resync !== true) {
// Prevent repair infinite loop if person document is not synchronized
// This is the first automatic synchro to init DB
return wrapJioCall(gadget, 'repair')
.push(function () {
return setUserTitle(gadget, true);
});
}
return gadget.setSetting('user_title', '');
}
return gadget.setSetting('user_title', '')
.push(function () {
throw error;
});
});
}
rJS(window)
.ready(function (gadget) {
alertify.set({ delay: 1500 });
gadget.state_parameter_dict = {
authenticated: false
};
})
.declareAcquiredMethod('setSetting', 'setSetting')
.declareAcquiredMethod('getSetting', 'getSetting')
.declareAcquiredMethod('getUrlFor', 'getUrlFor')
.declareAcquiredMethod('redirect', 'redirect')
.declareAcquiredMethod("getUrlParameter", "getUrlParameter")
.declareMethod('createJio', function () {
var gadget = this,
tmp = hashParams(),
hateoas_url,
default_view,
me;
me = tmp['n.me'] || '';
return new RSVP.Queue()
.push(function () {
if (me) {
return gadget.setSetting('me', me);
}
})
.push(function () {
return RSVP.all([
gadget.getSetting('hateoas_url'),
gadget.getSetting('default_view_reference'),
gadget.getSetting('me')
]);
})
.push(function (setting_list) {
var jio_storage;
hateoas_url = setting_list[0];
default_view = setting_list[1];
me = setting_list[2];
if (!me) {
jio_storage = jIO.createJIO({
type: "erp5",
url: setting_list[0],
default_view_reference: setting_list[1]
});
return wrapJioCall(gadget, 'getAttachment', ['acl_users', hateoas_url, {format: "json"}], jio_storage)
.push(function (result) {
me = result._links.me.href;
return gadget.setSetting('me', me);
});
}
})
.push(function () {
var current_date = new Date(),
new_date = new Date(
current_date.getFullYear(),
current_date.getMonth(),
current_date.getDate() - 60
);
gadget.state_parameter_dict.me = me;
//gadget.state_parameter_dict.authenticated = true;
gadget.state_parameter_dict.jio_storage = jIO.createJIO({
type: "replicate",
// XXX This drop the signature lists...
query: {
query: '(portal_type: "Expense Record" AND (simulation_state:"draft" OR simulation_state:"sent" OR simulation_state:"stopped")) ' +
'OR (portal_type: "Travel Request Record" AND (simulation_state:"draft" OR simulation_state:"sent" OR simulation_state:"stopped")) ' +
'OR (portal_type: "Leave Report Record" AND simulation_state:"stopped") ' +
'OR (portal_type: "Leave Request Record" AND (simulation_state:"draft" OR simulation_state:"sent" OR simulation_state:"stopped")) ' +
'OR (portal_type: "Localisation Record" AND (simulation_state:"draft" OR simulation_state:"stopped")) ' +
'OR (portal_type: "Expense Sheet" AND (reference: "expense_sheet")) ' +
'OR (portal_type: "Currency" AND validation_state:"validated") ' +
'OR (portal_type: "Service" AND validation_state:"validated") ' +
'OR (portal_type: "Person" AND id: "' + me.split("/")[1] + '")',
limit: [0, 1234567890]
},
use_remote_post: true,
conflict_handling: 2,
check_local_modification: false,
check_local_creation: true,
check_local_deletion: false,
check_remote_modification: false,
check_remote_creation: true,
check_remote_deletion: true,
local_sub_storage: {
type: "query",
sub_storage: {
type: "uuid",
sub_storage: {
type: "indexeddb",
database: "mmr-erp5-tmp"
}
}
},
remote_sub_storage: {
type: "erp5",
url: hateoas_url,
default_view_reference: default_view
},
signature_sub_storage: {
type: "query",
sub_storage: {
type: "indexeddb",
database: "expense-hash-list"
}
}
});
});
})
.declareMethod('get', function () {
return wrapJioCall(this, 'get', arguments);
})
.declareMethod('getAttachment', function () {
if (this.state_parameter_dict.online) {
return wrapJioCall(this, 'getAttachment', [arguments[0], arguments[1], {format: "json"}]);
}
return wrapJioCall(this, 'getAttachment', [arguments[0], arguments[1], {format: "json"}], this.state_parameter_dict.jio_storage.__storage._remote_sub_storage);
})
.declareMethod('post', function () {
return wrapJioCall(this, 'post', arguments);
})
.declareMethod('put', function () {
return wrapJioCall(this, 'put', arguments);
})
.declareMethod('remove', function () {
return wrapJioCall(this, 'remove', arguments);
})
.declareMethod('repair', function () {
var gadget = this;
return wrapJioCall(this, 'repair', arguments)
.push(function () {
return setUserTitle(gadget);
})
.push(function () {
return gadget.setSetting('last_sync_date', new Date().toLocaleString());
});
})
.declareMethod('allDocs', function () {
if (arguments[0].query) {
if (arguments[0].query.indexOf('relative_url') !== -1) {
return this.getSetting('user_title')
.push(function (result) {
return {
'data': {
'rows': [{
'value': {
'title': result
}
}]
}
};
});
}
}
return wrapJioCall(this, 'allDocs', arguments);
});
}(window, rJS, RSVP, jIO, UriTemplate, alertify, indexedDB));
\ No newline at end of file
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Web Script" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_Access_contents_information_Permission</string> </key>
<value>
<tuple>
<string>Anonymous</string>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Auditor</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Add_portal_content_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Change_local_roles_Permission</string> </key>
<value>
<tuple>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Modify_portal_content_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_View_Permission</string> </key>
<value>
<tuple>
<string>Anonymous</string>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Auditor</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>contributor/person_module/2</string>
<string>contributor/person_module/5</string>
</tuple>
</value>
</item>
<item>
<key> <string>content_md5</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>default_reference</string> </key>
<value> <string>gadget_hr_jio.js</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>gadget_hr_jio_js</string> </value>
</item>
<item>
<key> <string>language</string> </key>
<value> <string>en</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Web Script</string> </value>
</item>
<item>
<key> <string>short_title</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>HR Gadget JS</string> </value>
</item>
<item>
<key> <string>version</string> </key>
<value> <string>001</string> </value>
</item>
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary>
<item>
<key> <string>document_publication_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
<item>
<key> <string>edit_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value>
</item>
<item>
<key> <string>processing_status_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAU=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>publish_alive</string> </value>
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>zope</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>error_message</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>time</string> </key>
<value>
<object>
<klass>
<global name="DateTime" module="DateTime.DateTime"/>
</klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>1479221739.78</float>
<string>UTC</string>
</tuple>
</state>
</object>
</value>
</item>
<item>
<key> <string>validation_state</string> </key>
<value> <string>published_alive</string> </value>
</item>
</dictionary>
</list>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>edit</string> </value>
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>zope</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>error_message</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>966.50115.49905.16025</string> </value>
</item>
<item>
<key> <string>state</string> </key>
<value> <string>current</string> </value>
</item>
<item>
<key> <string>time</string> </key>
<value>
<object>
<klass>
<global name="DateTime" module="DateTime.DateTime"/>
</klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>1523364927.08</float>
<string>GMT+2</string>
</tuple>
</state>
</object>
</value>
</item>
</dictionary>
</list>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="5" aka="AAAAAAAAAAU=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>detect_converted_file</string> </value>
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>zope</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>error_message</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>external_processing_state</string> </key>
<value> <string>converted</string> </value>
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>0.0.0.0</string> </value>
</item>
<item>
<key> <string>time</string> </key>
<value>
<object>
<klass>
<global name="DateTime" module="DateTime.DateTime"/>
</klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>1479221698.05</float>
<string>UTC</string>
</tuple>
</state>
</object>
</value>
</item>
</dictionary>
</list>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -241,7 +241,7 @@
parent_relative_url: "record_module",
portal_type: "Leave Request Record",
source_reference: source_reference,
modification_date: new Date().toISOString()
modification_date: new Date().toISOString().slice(0, 10).replace(/-/g, "/")
};
for (i = 0; i < submit_event.target.length; i += 1) {
// XXX Should check input type instead
......
......@@ -250,7 +250,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>989.27549.43950.31078</string> </value>
<value> <string>994.55194.7094.63129</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -268,7 +268,7 @@
</tuple>
<state>
<tuple>
<float>1613394086.14</float>
<float>1631870226.12</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -250,7 +250,7 @@
source_reference: source_reference,
visible_in_html5_app_flag: 1,
record_revision: (gadget.options.doc.record_revision || 1),
modification_date: new Date().toISOString()
modification_date: new Date().toISOString().slice(0, 10).replace(/-/g, "/")
};
for (i = 0; i < submit_event.target.length; i += 1) {
// XXX Should check input type instead
......
......@@ -250,7 +250,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>989.27549.43950.31078</string> </value>
<value> <string>994.55194.7094.63129</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -268,7 +268,7 @@
</tuple>
<state>
<tuple>
<float>1613394114.93</float>
<float>1631870363.32</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -9,6 +9,7 @@
<script src="rsvp.js"></script>
<script src="renderjs.js"></script>
<script src="jiodev.js" type="text/javascript"></script>
<script src="gadget_officejs_hr_tool.js" type="text/javascript"></script>
<script src="gadget_officejs_page_jio_erp5_configurator.js"></script>
......
......@@ -246,7 +246,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>966.52991.40280.18790</string> </value>
<value> <string>994.52542.52680.32887</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -264,8 +264,8 @@
</tuple>
<state>
<tuple>
<float>1523626101.75</float>
<string>GMT+2</string>
<float>1631713807.8</float>
<string>UTC</string>
</tuple>
</state>
</object>
......
/*global window, rJS, RSVP, URI, location,
/*global window, rJS, RSVP, URI, location, getSynchronizeQuery,
btoa */
/*jslint nomen: true, indent: 2, maxerr: 3*/
(function (window, rJS, RSVP, loopEventListener) {
"use strict";
function setjIOERP5Configuration(gadget) {
var erp5_url = gadget.props.element.querySelector("input[name='erp5_url']").value;
var erp5_url = gadget.props.element.querySelector("input[name='erp5_url']").value,
original_query = getSynchronizeQuery(null);
return gadget.setSetting("me", '')
.push(function () {
var configuration = {
type: "replicate",
query: {
query: '(portal_type: "Expense Record" AND (simulation_state:"draft" OR simulation_state:"sent" OR simulation_state:"stopped")) ' +
'OR (portal_type: "Travel Request Record" AND (simulation_state:"draft" OR simulation_state:"sent" OR simulation_state:"stopped")) ' +
'OR (portal_type: "Leave Report Record" AND simulation_state:"stopped") ' +
'OR (portal_type: "Leave Request Record" AND (simulation_state:"draft" OR simulation_state:"sent" OR simulation_state:"stopped")) ' +
'OR (portal_type: "Localisation Record" AND (simulation_state:"draft" OR simulation_state:"stopped")) ' +
'OR (portal_type: "Expense Sheet" AND (reference: "expense_sheet")) ' +
'OR (portal_type: "Currency" AND validation_state:"validated") ' +
'OR (portal_type: "Service" AND validation_state:"validated") ',
query: original_query,
limit: [0, 1234567890]
},
use_remote_post: true,
......
......@@ -245,7 +245,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>989.27549.43950.31078</string> </value>
<value> <string>994.52549.19733.34850</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -263,7 +263,7 @@
</tuple>
<state>
<tuple>
<float>1613394309.96</float>
<float>1631711329.34</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -10,6 +10,8 @@
<script src="renderjs.js" type="text/javascript"></script>
<script src="jiodev.js" type="text/javascript"></script>
<script src="gadget_officejs_hr_tool.js" type="text/javascript"></script>
<!-- custom script -->
<script src="gadget_officejs_hr_jio.js" type="text/javascript"></script>
......
......@@ -246,7 +246,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>966.52672.52784.27187</string> </value>
<value> <string>994.52543.36230.12339</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -264,8 +264,8 @@
</tuple>
<state>
<tuple>
<float>1523518145.13</float>
<string>GMT+2</string>
<float>1631713769.69</float>
<string>UTC</string>
</tuple>
</state>
</object>
......
......@@ -56,6 +56,7 @@
.declareAcquiredMethod("redirect", "redirect")
.declareAcquiredMethod("getSetting", "getSetting")
.declareAcquiredMethod("getSettingList", "getSettingList")
.declareAcquiredMethod("setSetting", "setSetting")
.declareMethod('createJio', function (jio_options) {
......@@ -99,31 +100,87 @@
.declareMethod('repair', function () {
var gadget = this;
return this.getSetting("jio_storage_name")
.push(function (jio_storage_name) {
//try to specify me
if (jio_storage_name === 'ERP5') {
return gadget.getSetting('me')
.push(function (me) {
if (!me) {
return gadget.getSetting('jio_storage_description')
.push(function (configuration) {
gadget.state_parameter_dict.jio_storage = jIO.createJIO(configuration.remote_sub_storage);
return wrapJioCall(gadget, 'getAttachment', ['acl_users', configuration.remote_sub_storage.url, {format: "json"}])
.push(function (result) {
//recreate erp5 storage with indexeddb
me = result._links.me ? result._links.me.href : 'manager';
configuration.query.query += 'OR (portal_type: "Person" AND id: "' + me.split("/")[1] + '")',
gadget.state_parameter_dict.jio_storage = jIO.createJIO(configuration);
return gadget.setSetting('me', me);
})
.push(function () {
return gadget.setSetting('jio_storage_description', configuration);
});
});
}
});
.push(function (jio_storage_name) {
if (jio_storage_name === 'ERP5') {
return gadget.getSettingList(['jio_storage_description', 'me'])
.push(function (result_list) {
var additional_query_list = [],
service_query = new ComplexQuery({
operator: 'OR',
query_list: [],
type: "complex"
}),
me;
gadget.state_parameter_dict.jio_storage = jIO.createJIO(result_list[0].remote_sub_storage);
return wrapJioCall(gadget, 'allDocs', [
{
"query": '(selection_domain_use:"hr" AND translated_validation_state_title: "validated")',
"limit": [0, 1000]
}
])
.push(function (result) {
var i;
if (result.data.rows.length) {
for (i = 0; i < result.data.rows.length; i += 1) {
service_query.query_list.push(new SimpleQuery({
key: 'id',
operator: '',
type: "simple",
value: result.data.rows[i].id.split('/')[1]
}));
}
additional_query_list.push(new ComplexQuery({
operator: 'AND',
query_list: [
new SimpleQuery({
key: 'portal_type',
operator: '',
type: "simple",
value: 'Service'
}),
service_query
],
type: "complex"
}));
}
if (! result_list[1]) {
return wrapJioCall(gadget, 'getAttachment', ['acl_users', result_list[0].remote_sub_storage.url, {format: "json"}])
.push(function (result) {
me = result._links.me ? result._links.me.href : 'manager';
return gadget.setSetting('me', me);
})
} else {
me = result_list[1];
}
})
.push(function () {
additional_query_list.push(new ComplexQuery({
operator: 'AND',
query_list: [
new SimpleQuery({
key: 'portal_type',
operator: '',
type: "simple",
value: 'Person'
}),
new SimpleQuery({
key: 'id',
operator: '',
type: "simple",
value: me.split("/")[1]
})
],
type: "complex"
}));
result_list[0].query.query = getSynchronizeQuery(additional_query_list);
gadget.state_parameter_dict.jio_storage = jIO.createJIO(result_list[0]);
return gadget.setSetting('jio_storage_description', result_list[0]);
});
});
}
})
})
.push(function () {
return wrapJioCall(gadget, 'repair', arguments);
})
......
......@@ -245,7 +245,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>966.59878.54409.55825</string> </value>
<value> <string>994.52646.4747.8277</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -263,8 +263,8 @@
</tuple>
<state>
<tuple>
<float>1523950559.17</float>
<string>GMT+2</string>
<float>1631780404.96</float>
<string>UTC</string>
</tuple>
</state>
</object>
......
/*global window, RSVP, FileReader */
/*global window, RSVP, FileReader, QueryFactory, SimpleQuery, ComplexQuery, Query */
/*jslint indent: 2, maxerr: 3, unparam: true */
(function (window, RSVP) {
"use strict";
......@@ -96,4 +96,271 @@
}
return String.fromCharCode(random())+String.fromCharCode(random())+String.fromCharCode(random());
};
window.getSynchronizeQuery = function (additional_query_list) {
var basic_query,
expense_record_query,
travel_request_record_query,
leave_report_record_query,
leave_request_record_query,
localisation_record_query,
expense_sheet_query,
currency_query,
six_month_ago,
one_year_ago;
six_month_ago = new Date();
six_month_ago.setMonth(six_month_ago.getMonth() - 6);
six_month_ago = six_month_ago.toISOString().slice(0, 10).replace(/-/g, "/");
one_year_ago = new Date();
one_year_ago.setFullYear(one_year_ago.getFullYear() - 1);
one_year_ago = one_year_ago.toISOString().slice(0, 10).replace(/-/g, "/");
expense_record_query = new ComplexQuery({
operator: 'AND',
query_list: [
new SimpleQuery({
key: 'portal_type',
operator: '',
type: "simple",
value: 'Expense Record'
}),
new SimpleQuery({
key: 'modification_date',
operator: '>',
type: "simple",
value: six_month_ago
}),
new ComplexQuery({
operator: 'OR',
query_list: [
new SimpleQuery({
key: 'simulation_state',
operator: '',
type: "simple",
value: "draft"
}),
new SimpleQuery({
key: 'simulation_state',
operator: '',
type: "simple",
value: "sent"
}),
new SimpleQuery({
key: 'simulation_state',
operator: '',
type: "simple",
value: "stopped"
})
],
type: "complex"
})
],
type: "complex"
});
travel_request_record_query = new ComplexQuery({
operator: 'AND',
query_list: [
new SimpleQuery({
key: 'portal_type',
operator: '',
type: "simple",
value: 'Travel Request Record'
}),
new SimpleQuery({
key: 'modification_date',
operator: '>',
type: "simple",
value: six_month_ago
}),
new ComplexQuery({
operator: 'OR',
query_list: [
new SimpleQuery({
key: 'simulation_state',
operator: '',
type: "simple",
value: "draft"
}),
new SimpleQuery({
key: 'simulation_state',
operator: '',
type: "simple",
value: "sent"
}),
new SimpleQuery({
key: 'simulation_state',
operator: '',
type: "simple",
value: "stopped"
})
],
type: "complex"
})
],
type: "complex"
});
leave_report_record_query = new ComplexQuery({
operator: 'AND',
query_list: [
new SimpleQuery({
key: 'portal_type',
operator: '',
type: "simple",
value: 'Leave Report Record'
}),
new SimpleQuery({
key: 'modification_date',
operator: '>',
type: "simple",
value: six_month_ago
}),
new SimpleQuery({
key: 'simulation_state',
operator: '',
type: "simple",
value: "stopped"
})
],
type: "complex"
});
leave_request_record_query = new ComplexQuery({
operator: 'AND',
query_list: [
new SimpleQuery({
key: 'portal_type',
operator: '',
type: "simple",
value: 'Leave Request Record'
}),
new SimpleQuery({
key: 'modification_date',
operator: '>',
type: "simple",
value: one_year_ago
}),
new ComplexQuery({
operator: 'OR',
query_list: [
new SimpleQuery({
key: 'simulation_state',
operator: '',
type: "simple",
value: "draft"
}),
new SimpleQuery({
key: 'simulation_state',
operator: '',
type: "simple",
value: "sent"
}),
new SimpleQuery({
key: 'simulation_state',
operator: '',
type: "simple",
value: "stopped"
})
],
type: "complex"
})
],
type: "complex"
});
localisation_record_query = new ComplexQuery({
operator: 'AND',
query_list: [
new SimpleQuery({
key: 'portal_type',
operator: '',
type: "simple",
value: 'Localisation Record'
}),
new SimpleQuery({
key: 'modification_date',
operator: '>',
type: "simple",
value: six_month_ago
}),
new ComplexQuery({
operator: 'OR',
query_list: [
new SimpleQuery({
key: 'simulation_state',
operator: '',
type: "simple",
value: "draft"
}),
new SimpleQuery({
key: 'simulation_state',
operator: '',
type: "simple",
value: "stopped"
})
],
type: "complex"
})
],
type: "complex"
});
expense_sheet_query = new ComplexQuery({
operator: 'AND',
query_list: [
new SimpleQuery({
key: 'portal_type',
operator: '',
type: "simple",
value: 'Expense Sheet'
}),
new SimpleQuery({
key: 'reference',
operator: '',
type: "simple",
value: "expense_sheet"
})
],
type: "complex"
});
currency_query = new ComplexQuery({
operator: 'AND',
query_list: [
new SimpleQuery({
key: 'portal_type',
operator: '',
type: "simple",
value: 'Currency'
}),
new SimpleQuery({
key: 'validation_state',
operator: '',
type: "simple",
value: "validated"
})
],
type: "complex"
});
basic_query = new ComplexQuery({
operator: 'OR',
type: 'complex',
query_list: [
expense_record_query,
travel_request_record_query,
leave_report_record_query,
leave_request_record_query,
localisation_record_query,
expense_sheet_query,
currency_query
]
});
if (additional_query_list) {
basic_query.query_list = basic_query.query_list.concat(additional_query_list);
}
return Query.objectToSearchText(basic_query);
};
}(window, RSVP));
\ No newline at end of file
......@@ -240,7 +240,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>956.57355.19823.14643</string> </value>
<value> <string>994.42603.26741.38963</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -258,7 +258,7 @@
</tuple>
<state>
<tuple>
<float>1485347131.83</float>
<float>1631713737.85</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -4,6 +4,7 @@
</portal_type>
<portal_type id="Expense Validation Request">
<item>ExpenseValidationRequest</item>
<item>ExpenseValidationRequestConstraint</item>
</portal_type>
<portal_type id="Leave Request Record">
<item>LeaveRequestRecord</item>
......
......@@ -279,7 +279,7 @@
<dictionary>
<item>
<key> <string>_text</string> </key>
<value> <string>python: here.getModificationDate().HTML4()</string> </value>
<value> <string>python: here.getModificationDate().Date()</string> </value>
</item>
</dictionary>
</pickle>
......
......@@ -279,7 +279,7 @@
<dictionary>
<item>
<key> <string>_text</string> </key>
<value> <string>python: here.getModificationDate().HTML4()</string> </value>
<value> <string>python: here.getModificationDate().Date()</string> </value>
</item>
</dictionary>
</pickle>
......
......@@ -279,7 +279,7 @@
<dictionary>
<item>
<key> <string>_text</string> </key>
<value> <string>python: here.getModificationDate().HTML4()</string> </value>
<value> <string>python: here.getModificationDate().Date()</string> </value>
</item>
</dictionary>
</pickle>
......
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