Commit c0f6c7a7 authored by Xiaowu Zhang's avatar Xiaowu Zhang

erp5_travel_expense: group common functions and don't call several setSetting in rsvp.all

parent 8101fa34
......@@ -66,10 +66,7 @@
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>contributor/person_module/1</string>
<string>contributor/person_module/2</string>
</tuple>
<tuple/>
</value>
</item>
<item>
......@@ -200,12 +197,13 @@ chartist.min.js\n
chartist.min.css\n
gadget_hr_jio.html\n
gadget_hr_jio.js\n
gadget_officejs_jio_text_post.html\n
gadget_officejs_jio_text_post.js\n
gadget_common.js\n
gadget_officejs_page_calendar.js\n
gadget_officejs_page_calendar.html\n
gadget_hr_tool.js\n
\n
\n
\n
>>>>>>> e7eb1b5... erp5_travel_expense: add calendar gadget to display events in a person agenda
NETWORK:\n
*
......@@ -330,7 +328,7 @@ NETWORK:\n
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>supercedriclen</string> </value>
<value> <string>zope</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
......@@ -344,11 +342,7 @@ NETWORK:\n
</item>
<item>
<key> <string>serial</string> </key>
<<<<<<< HEAD
<value> <string>955.64169.17995.61457</string> </value>
=======
<value> <string>956.35741.51905.15616</string> </value>
>>>>>>> e7eb1b5... erp5_travel_expense: add calendar gadget to display events in a person agenda
<value> <string>956.44619.55889.62941</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -366,11 +360,7 @@ NETWORK:\n
</tuple>
<state>
<tuple>
<<<<<<< HEAD
<float>1481818221.17</float>
=======
<float>1484044668.41</float>
>>>>>>> e7eb1b5... erp5_travel_expense: add calendar gadget to display events in a person agenda
<float>1484577398.16</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -13,6 +13,7 @@
<script src="gadget_global.js" ></script>
<script src="handlebars.js"></script>
<script src="alertify.js"></script>
<script src="gadget_officejs_hr_tool.js"></script>
<script id="relation-listview-template" type="text/x-handlebars-template">
......
......@@ -246,7 +246,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>956.40028.61290.1433</string> </value>
<value> <string>956.44329.14852.21316</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -264,7 +264,7 @@
</tuple>
<state>
<tuple>
<float>1484312287.56</float>
<float>1484576962.29</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -64,17 +64,6 @@
return doc;
});
}
function getWorkflowState(id, sync_flag) {
var sync_state;
if(id.indexOf("_module/") > 0){
sync_state = "Synced";
}else if(sync_flag){
sync_state = "Not Synced";
}else{
sync_state = "Not Ready To Sync";
}
return sync_state;
}
function getTypeSelectList(gadget, doc) {
return new RSVP.Queue()
......@@ -104,82 +93,6 @@
});
}
function geoLocationPromise() {
return new Promise(function (resolve, reject) {
var err;
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function (result) {
resolve(result);
}, function (error) {
switch(error.code) {
case error.PERMISSION_DENIED:
err = new Error("User denied the request for Geolocation");
break;
case error.POSITION_UNAVAILABLE:
err = new Error("Location information is unavailable");
break;
case error.TIMEOUT:
err = new Error("The request to get user location timed out");
break;
default:
err = new Error("An unknown error occurred");
break;
}
reject(err);
},
{maximumAge:60000, timeout:20000});
} else {
reject(new Error("Geolocation is not supported by this browser"));
}
});
}
function getSequentialID(gadget, record_type_prefix){
var last_sequential_id,
prefix,
date = new Date(),
date_text = date.getFullYear()+('0'+(date.getMonth()+1)).slice(-2)+('0'+date.getDate()).slice(-2);
return new RSVP.Queue()
.push(function () {
if (gadget.options.doc.source_reference) {
return gadget.options.doc.source_reference;
} else {
return new RSVP.Queue()
.push(function () {
return new RSVP.all([
gadget.getSetting('last_sequential_id'),
gadget.getSetting('sequential_id_prefix')
]);
})
.push(function (result_list) {
if (result_list[0]) {
last_sequential_id = Number(result_list[0]);
} else {
last_sequential_id = 0;
}
last_sequential_id += 1;
if (result_list[1]) {
prefix = result_list[1];
} else {
prefix = getRandomPrefixForID();
}
return RSVP.all([
gadget.setSetting('last_sequential_id', last_sequential_id),
gadget.setSetting('sequential_id_prefix', prefix)
]);
})
.push(function () {
return record_type_prefix + '-' + date_text + '-' + prefix + ('0000'+last_sequential_id).slice(-5);
});
}
});
}
function getRandomPrefixForID(){
function random(){
return 65 + Math.floor( Math.random() * 26 );
}
return String.fromCharCode(random())+String.fromCharCode(random())+String.fromCharCode(random());
}
gadget_klass
.ready(function (g) {
......
......@@ -242,7 +242,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>956.40024.27967.8789</string> </value>
<value> <string>956.44593.2775.8567</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -260,7 +260,7 @@
</tuple>
<state>
<tuple>
<float>1484301997.49</float>
<float>1484576848.98</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -12,6 +12,7 @@
<script src="gadget_global.js" ></script>
<script src="handlebars.js"></script>
<script src="alertify.js"></script>
<script src="gadget_officejs_hr_tool.js"></script>
......
......@@ -246,7 +246,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>956.37052.29099.3498</string> </value>
<value> <string>956.44329.14852.21316</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -264,7 +264,7 @@
</tuple>
<state>
<tuple>
<float>1484240093.48</float>
<float>1484576952.21</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -26,95 +26,6 @@
};
function getWorkflowState(id, sync_flag) {
var sync_state;
if(id.indexOf("_module/") > 0){
sync_state = "Synced";
}else if(sync_flag){
sync_state = "Not Synced";
}else{
sync_state = "Not Ready To Sync";
}
return sync_state;
}
function geoLocationPromise() {
return new Promise(function (resolve, reject) {
var err;
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function (result) {
resolve(result);
}, function (error) {
switch(error.code) {
case error.PERMISSION_DENIED:
err = new Error("User denied the request for Geolocation");
break;
case error.POSITION_UNAVAILABLE:
err = new Error("Location information is unavailable");
break;
case error.TIMEOUT:
err = new Error("The request to get user location timed out");
break;
default:
err = new Error("An unknown error occurred");
break;
}
reject(err);
},
{maximumAge:60000, timeout:20000});
} else {
reject(new Error("Geolocation is not supported by this browser"));
}
});
}
function getSequentialID(gadget, record_type_prefix){
var last_sequential_id,
prefix,
date = new Date(),
date_text = date.getFullYear()+('0'+(date.getMonth()+1)).slice(-2)+('0'+date.getDate()).slice(-2);
return new RSVP.Queue()
.push(function () {
if (gadget.options.doc.source_reference) {
return gadget.options.doc.source_reference;
} else {
return new RSVP.Queue()
.push(function () {
return new RSVP.all([
gadget.getSetting('last_sequential_id'),
gadget.getSetting('sequential_id_prefix')
]);
})
.push(function (result_list) {
if (result_list[0]) {
last_sequential_id = Number(result_list[0]);
} else {
last_sequential_id = 0;
}
last_sequential_id += 1;
if (result_list[1]) {
prefix = result_list[1];
} else {
prefix = getRandomPrefixForID();
}
return RSVP.all([
gadget.setSetting('last_sequential_id', last_sequential_id),
gadget.setSetting('sequential_id_prefix', prefix)
]);
})
.push(function () {
return record_type_prefix + '-' + date_text + '-' + prefix + ('0000'+last_sequential_id).slice(-5);
});
}
});
}
function getRandomPrefixForID(){
function random(){
return 65 + Math.floor( Math.random() * 26 );
}
return String.fromCharCode(random())+String.fromCharCode(random())+String.fromCharCode(random());
}
gadget_klass
.ready(function (g) {
return g.getElement()
......
......@@ -244,7 +244,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>956.38999.14763.58112</string> </value>
<value> <string>956.44329.14852.21316</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -262,7 +262,7 @@
</tuple>
<state>
<tuple>
<float>1484240163.15</float>
<float>1484576839.9</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -12,6 +12,7 @@
<script src="gadget_global.js" ></script>
<script src="handlebars.js"></script>
<script src="alertify.js"></script>
<script src="gadget_officejs_hr_tool.js"></script>
......
......@@ -246,7 +246,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>956.38978.20050.22596</string> </value>
<value> <string>956.44329.14852.21316</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -264,7 +264,7 @@
</tuple>
<state>
<tuple>
<float>1484301861.21</float>
<float>1484576937.72</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -42,95 +42,6 @@
});
}
function getWorkflowState(id, sync_flag) {
var sync_state;
if(id.indexOf("_module/") > 0){
sync_state = "Synced";
}else if(sync_flag){
sync_state = "Not Synced";
}else{
sync_state = "Not Ready To Sync";
}
return sync_state;
}
function geoLocationPromise() {
return new Promise(function (resolve, reject) {
var err;
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function (result) {
resolve(result);
}, function (error) {
switch(error.code) {
case error.PERMISSION_DENIED:
err = new Error("User denied the request for Geolocation");
break;
case error.POSITION_UNAVAILABLE:
err = new Error("Location information is unavailable");
break;
case error.TIMEOUT:
err = new Error("The request to get user location timed out");
break;
default:
err = new Error("An unknown error occurred");
break;
}
reject(err);
},
{maximumAge:60000, timeout:20000});
} else {
reject(new Error("Geolocation is not supported by this browser"));
}
});
}
function getSequentialID(gadget, record_type_prefix){
var last_sequential_id,
prefix,
date = new Date(),
date_text = date.getFullYear()+('0'+(date.getMonth()+1)).slice(-2)+('0'+date.getDate()).slice(-2);
return new RSVP.Queue()
.push(function () {
if (gadget.options.doc.doc_id) {
return gadget.options.doc.doc_id;
} else {
return new RSVP.Queue()
.push(function () {
return new RSVP.all([
gadget.getSetting('last_sequential_id'),
gadget.getSetting('sequential_id_prefix')
]);
})
.push(function (result_list) {
if (result_list[0]) {
last_sequential_id = Number(result_list[0]);
} else {
last_sequential_id = 0;
}
last_sequential_id += 1;
if (result_list[1]) {
prefix = result_list[1];
} else {
prefix = getRandomPrefixForID();
}
return RSVP.all([
gadget.setSetting('last_sequential_id', last_sequential_id),
gadget.setSetting('sequential_id_prefix', prefix)
]);
})
.push(function () {
return record_type_prefix + '-' + date_text + '-' + prefix + ('0000'+last_sequential_id).slice(-5);
});
}
});
}
function getRandomPrefixForID(){
function random(){
return 65 + Math.floor( Math.random() * 26 );
}
return String.fromCharCode(random())+String.fromCharCode(random())+String.fromCharCode(random());
}
gadget_klass
.ready(function (g) {
return g.getElement()
......
......@@ -244,7 +244,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>956.40024.39635.59818</string> </value>
<value> <string>956.44329.14852.21316</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -262,7 +262,7 @@
</tuple>
<state>
<tuple>
<float>1484301994.5</float>
<float>1484576818.21</float>
<string>UTC</string>
</tuple>
</state>
......
/*global window, RSVP, FileReader */
/*jslint indent: 2, maxerr: 3, unparam: true */
(function (window, RSVP) {
"use strict";
window.getWorkflowState = function (id, sync_flag) {
var sync_state;
if(id.indexOf("_module/") > 0){
sync_state = "Synced";
}else if(sync_flag){
sync_state = "Not Synced";
}else{
sync_state = "Not Ready To Sync";
}
return sync_state;
};
window.getLocationPromise = function() {
return new Promise(function (resolve, reject) {
var err;
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function (result) {
resolve(result);
}, function (error) {
switch(error.code) {
case error.PERMISSION_DENIED:
err = new Error("User denied the request for Geolocation");
break;
case error.POSITION_UNAVAILABLE:
err = new Error("Location information is unavailable");
break;
case error.TIMEOUT:
err = new Error("The request to get user location timed out");
break;
default:
err = new Error("An unknown error occurred");
break;
}
reject(err);
},
{maximumAge:60000, timeout:20000});
} else {
reject(new Error("Geolocation is not supported by this browser"));
}
});
};
window.getSequentialID = function (gadget, record_type_prefix){
var last_sequential_id,
prefix,
date = new Date(),
date_text = date.getFullYear()+('0'+(date.getMonth()+1)).slice(-2)+('0'+date.getDate()).slice(-2);
return new RSVP.Queue()
.push(function () {
if (gadget.options.doc.source_reference) {
return gadget.options.doc.source_reference;
} else {
return new RSVP.Queue()
.push(function () {
return new RSVP.all([
gadget.getSetting('last_sequential_id'),
gadget.getSetting('sequential_id_prefix')
]);
})
.push(function (result_list) {
if (result_list[0]) {
last_sequential_id = Number(result_list[0]);
} else {
last_sequential_id = 0;
}
last_sequential_id += 1;
if (result_list[1]) {
prefix = result_list[1];
} else {
prefix = getRandomPrefixForID();
}
return gadget.setSetting('sequential_id_prefix', prefix);
})
.push(function () {
return gadget.setSetting('last_sequential_id', last_sequential_id);
})
.push(function () {
return record_type_prefix + '-' + date_text + '-' + prefix + ('0000'+last_sequential_id).slice(-5);
});
}
});
};
window.getRandomPrefixForID = function(){
function random(){
return 65 + Math.floor( Math.random() * 26 );
}
return String.fromCharCode(random())+String.fromCharCode(random())+String.fromCharCode(random());
};
}(window, RSVP));
\ 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>content_md5</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>text/javascript</string> </value>
</item>
<item>
<key> <string>default_reference</string> </key>
<value> <string>gadget_officejs_hr_tool.js</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>gadget_hr_tool_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>Gadget hr tool 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.patches.WorkflowTool"/>
</pickle>
<pickle>
<tuple>
<none/>
<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>1484576352.63</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>
</tuple>
</pickle>
</record>
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
</pickle>
<pickle>
<tuple>
<none/>
<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>956.44618.20758.21367</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>1484577478.61</float>
<string>UTC</string>
</tuple>
</state>
</object>
</value>
</item>
</dictionary>
</list>
</tuple>
</pickle>
</record>
<record id="5" aka="AAAAAAAAAAU=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
</pickle>
<pickle>
<tuple>
<none/>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value>
<none/>
</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>empty</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>1484576287.05</float>
<string>UTC</string>
</tuple>
</state>
</object>
</value>
</item>
</dictionary>
</list>
</tuple>
</pickle>
</record>
</ZopeData>
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