@gudhub/core 1.1.101 → 1.1.103
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -79,9 +79,15 @@ export class ItemProcessor {
|
|
|
79
79
|
addressToEmit.item_id = item.item_id;
|
|
80
80
|
this.pipeService.emit("gh_item_update", addressToEmit, item);
|
|
81
81
|
//-- Looking for updated item in the main storage according to 'item_id'
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
82
|
+
|
|
83
|
+
const fundedItem =
|
|
84
|
+
app.items_list.find(
|
|
85
|
+
(storageItem) => storageItem.item_id == item.item_id
|
|
86
|
+
) ||
|
|
87
|
+
app.trash_items.find(
|
|
88
|
+
(storageItem) => storageItem.item_id == item.item_id
|
|
89
|
+
);
|
|
90
|
+
|
|
85
91
|
if (fundedItem) {
|
|
86
92
|
//-- Updating value in existing fields
|
|
87
93
|
item.fields.forEach((field) => {
|
|
@@ -112,6 +118,17 @@ export class ItemProcessor {
|
|
|
112
118
|
);
|
|
113
119
|
}
|
|
114
120
|
});
|
|
121
|
+
|
|
122
|
+
const existsInList = app.items_list.some(
|
|
123
|
+
(listItem) => listItem.item_id === fundedItem.item_id
|
|
124
|
+
);
|
|
125
|
+
|
|
126
|
+
if (!existsInList) {
|
|
127
|
+
app.trash_items = app.trash_items.filter(
|
|
128
|
+
(trashItem) => trashItem.item_id !== fundedItem.item_id
|
|
129
|
+
);
|
|
130
|
+
app.items_list.push(fundedItem);
|
|
131
|
+
}
|
|
115
132
|
}
|
|
116
133
|
});
|
|
117
134
|
}
|
|
@@ -122,7 +139,17 @@ export class ItemProcessor {
|
|
|
122
139
|
const app = await this.appProcessor.getApp(app_id);
|
|
123
140
|
if (app) {
|
|
124
141
|
app.items_list = app.items_list.filter(item => {
|
|
125
|
-
if(itemsForDelete.find(findedItem => item.item_id == findedItem.item_id)) {
|
|
142
|
+
if (itemsForDelete.find(findedItem => item.item_id == findedItem.item_id)) {
|
|
143
|
+
if (!app?.trash_items) {
|
|
144
|
+
app.trash_items = [];
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
app?.trash_items.push({
|
|
148
|
+
...item,
|
|
149
|
+
trash: true,
|
|
150
|
+
last_update: Date.now()
|
|
151
|
+
});
|
|
152
|
+
|
|
126
153
|
delete app.items_object[item.item_id];
|
|
127
154
|
return false;
|
|
128
155
|
}
|
|
@@ -170,8 +197,7 @@ export class ItemProcessor {
|
|
|
170
197
|
item_id: id,
|
|
171
198
|
trash: false
|
|
172
199
|
}));
|
|
173
|
-
|
|
174
|
-
return await this.updateItemsInStorage(app_id, updatedItems);
|
|
200
|
+
return await this.updateItems(app_id, preparedItemsList);
|
|
175
201
|
}
|
|
176
202
|
|
|
177
203
|
itemListeners() {
|
package/package.json
CHANGED
package/umd/library.min.js
CHANGED
|
@@ -264,7 +264,7 @@ var t=arguments[3];Object.defineProperty(exports,"__esModule",{value:!0}),export
|
|
|
264
264
|
},{"./createAngularModuleInstance.js":"osSN","./createClassInstance.js":"DsUm"}],"q0my":[function(require,module,exports) {
|
|
265
265
|
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.AppProcessor=void 0;var t=require("../consts.js");function e(t){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function r(t){return a(t)||n(t)||c(t)||i()}function i(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function n(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}function a(t){if(Array.isArray(t))return f(t)}function p(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);e&&(i=i.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,i)}return r}function s(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?p(Object(r),!0).forEach(function(e){o(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):p(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}function o(t,e,r){return(e=y(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function u(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=c(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var i=0,n=function(){};return{s:n,n:function(){return i>=t.length?{done:!0}:{done:!1,value:t[i++]}},e:function(t){throw t},f:n}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,p=!0,s=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return p=t.done,t},e:function(t){s=!0,a=t},f:function(){try{p||null==r.return||r.return()}finally{if(s)throw a}}}}function c(t,e){if(t){if("string"==typeof t)return f(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?f(t,e):void 0}}function f(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,i=Array(e);r<e;r++)i[r]=t[r];return i}function l(){var t,e,r="function"==typeof Symbol?Symbol:{},i=r.iterator||"@@iterator",n=r.toStringTag||"@@toStringTag";function a(r,i,n,a){var o=i&&i.prototype instanceof s?i:s,u=Object.create(o.prototype);return h(u,"_invoke",function(r,i,n){var a,s,o,u=0,c=n||[],f=!1,l={p:0,n:0,v:t,a:h,f:h.bind(t,4),d:function(e,r){return a=e,s=0,o=t,l.n=r,p}};function h(r,i){for(s=r,o=i,e=0;!f&&u&&!n&&e<c.length;e++){var n,a=c[e],h=l.p,v=a[2];r>3?(n=v===i)&&(o=a[(s=a[4])?5:(s=3,3)],a[4]=a[5]=t):a[0]<=h&&((n=r<2&&h<a[1])?(s=0,l.v=i,l.n=a[1]):h<v&&(n=r<3||a[0]>i||i>v)&&(a[4]=r,a[5]=i,l.n=v,s=0))}if(n||r>1)return p;throw f=!0,i}return function(n,c,v){if(u>1)throw TypeError("Generator is already running");for(f&&1===c&&h(c,v),s=c,o=v;(e=s<2?t:o)||!f;){a||(s?s<3?(s>1&&(l.n=-1),h(s,o)):l.n=o:l.v=o);try{if(u=2,a){if(s||(n="next"),e=a[n]){if(!(e=e.call(a,o)))throw TypeError("iterator result is not an object");if(!e.done)return e;o=e.value,s<2&&(s=0)}else 1===s&&(e=a.return)&&e.call(a),s<2&&(o=TypeError("The iterator does not provide a '"+n+"' method"),s=1);a=t}else if((e=(f=l.n<0)?o:r.call(i,l))!==p)break}catch(e){a=t,s=1,o=e}finally{u=1}}return{value:e,done:f}}}(r,n,a),!0),u}var p={};function s(){}function o(){}function u(){}e=Object.getPrototypeOf;var c=[][i]?e(e([][i]())):(h(e={},i,function(){return this}),e),f=u.prototype=s.prototype=Object.create(c);function v(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,u):(t.__proto__=u,h(t,n,"GeneratorFunction")),t.prototype=Object.create(f),t}return o.prototype=u,h(f,"constructor",u),h(u,"constructor",o),o.displayName="GeneratorFunction",h(u,n,"GeneratorFunction"),h(f),h(f,n,"Generator"),h(f,i,function(){return this}),h(f,"toString",function(){return"[object Generator]"}),(l=function(){return{w:a,m:v}})()}function h(t,e,r,i){var n=Object.defineProperty;try{n({},"",{})}catch(t){n=0}(h=function(t,e,r,i){if(e)n?n(t,e,{value:r,enumerable:!i,configurable:!i,writable:!i}):t[e]=r;else{var a=function(e,r){h(t,e,function(t){return this._invoke(e,r,t)})};a("next",0),a("throw",1),a("return",2)}})(t,e,r,i)}function v(t,e,r,i,n,a,p){try{var s=t[a](p),o=s.value}catch(t){return void r(t)}s.done?e(o):Promise.resolve(o).then(i,n)}function _(t){return function(){var e=this,r=arguments;return new Promise(function(i,n){var a=t.apply(e,r);function p(t){v(a,i,n,p,s,"next",t)}function s(t){v(a,i,n,p,s,"throw",t)}p(void 0)})}}function d(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function m(t,e){for(var r=0;r<e.length;r++){var i=e[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,y(i.key),i)}}function g(t,e,r){return e&&m(t.prototype,e),r&&m(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function y(t){var r=w(t,"string");return"symbol"==e(r)?r:r+""}function w(t,r){if("object"!=e(t)||!t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var n=i.call(t,r||"default");if("object"!=e(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===r?String:Number)(t)}var A=exports.AppProcessor=function(){return g(function t(e,r,i,n,a,p,s){d(this,t),this.storage=e,this.pipeService=r,this.req=i,this.ws=n,this.applistReceived=!1,this.activateSW=s,this.chunksManager=a,this.util=p,this.appListeners(),this.appRequestCache=new Map},[{key:"createNewAppApi",value:function(){var t=_(l().m(function t(e){var r,i;return l().w(function(t){for(;;)switch(t.n){case 0:return t.p=0,t.n=1,this.req.post({url:"/api/app/create",form:{app:JSON.stringify(e)}});case 1:return(r=t.v).from_apps_list=!0,t.a(2,r);case 2:return t.p=2,i=t.v,console.log(i),t.a(2,null)}},t,this,[[0,2]])}));return function(e){return t.apply(this,arguments)}}()},{key:"updateAppApi",value:function(){var t=_(l().m(function t(e){var r,i;return l().w(function(t){for(;;)switch(t.n){case 0:return t.p=0,t.n=1,this.req.post({url:"/api/app/update",form:{app:JSON.stringify(e)}});case 1:return r=t.v,t.a(2,r);case 2:return t.p=2,i=t.v,console.log(i),t.a(2,null)}},t,this,[[0,2]])}));return function(e){return t.apply(this,arguments)}}()},{key:"deleteAppApi",value:function(){var t=_(l().m(function t(e){var r,i;return l().w(function(t){for(;;)switch(t.n){case 0:return t.p=0,t.n=1,this.req.post({url:"/api/app/delete",form:{app_id:e}});case 1:return r=t.v,t.a(2,r);case 2:return t.p=2,i=t.v,console.log(i),t.a(2,null)}},t,this,[[0,2]])}));return function(e){return t.apply(this,arguments)}}()},{key:"getAppListApi",value:function(){var t=_(l().m(function t(){var e,r;return l().w(function(t){for(;;)switch(t.n){case 0:return t.p=0,t.n=1,this.req.get({url:"/api/applist/get"});case 1:return e=t.v,t.a(2,e.apps_list.map(function(t){return t.from_apps_list=!0,t}));case 2:return t.p=2,r=t.v,console.log(r),t.a(2,null)}},t,this,[[0,2]])}));return function(){return t.apply(this,arguments)}}()},{key:"getAppApi",value:function(){var t=_(l().m(function t(e){var r,i;return l().w(function(t){for(;;)switch(t.n){case 0:return t.p=0,t.n=1,this.req.get({url:"/api/app/get",params:{app_id:e}});case 1:return r=t.v,t.a(2,r);case 2:return t.p=2,i=t.v,console.log(i),t.a(2,null)}},t,this,[[0,2]])}));return function(e){return t.apply(this,arguments)}}()},{key:"getAppListFromStorage",value:function(){return this.storage.getAppsList()}},{key:"getAppFromStorage",value:function(t){var e=this.storage.getApp(t);return e&&e.field_list.length?e:null}},{key:"addNewAppToStorage",value:function(t){return this.storage.getAppsList().push(t)}},{key:"saveAppInStorage",value:function(t){t.items_object={};for(var e=0;e<t.items_list.length;e++){t.items_object[t.items_list[e].item_id]={};for(var r=0;r<t.items_list[e].fields.length;r++)t.items_object[t.items_list[e].item_id][t.items_list[e].fields[r].field_id]=t.items_list[e].fields[r]}var i=this.storage.getApp(t.app_id);return i?(t.from_apps_list=i.from_apps_list,t.permission=i.permission,this.storage.updateApp(t)):(t.from_apps_list=!1,this.addNewAppToStorage(t)),this.getAppFromStorage(t.app_id)}},{key:"updateAppFieldsAndViews",value:function(t){var e=this,r=this.getAppFromStorage(t.app_id);t.items_list=r.items_list,t.file_list=r.file_list,t.from_apps_list=r.from_apps_list,t.items_object=r.items_object,this.storage.updateApp(t),this.pipeService.emit("gh_app_views_update",{app_id:t.app_id},t.views_list),t.field_list.forEach(function(r){e.pipeService.emit("gh_model_update",{app_id:t.app_id,field_id:r.field_id},r)})}},{key:"updateAppInStorage",value:function(t){this.storage.getApp(t.app_id)?(this.storage.updateApp(t),this.pipeService.emit("gh_app_update",{app_id:t.app_id},t),this.pipeService.emit("gh_items_update",{app_id:t.app_id},t.items_list)):this.addNewAppToStorage(t)}},{key:"deletingAppFromStorage",value:function(t){var e=this.storage.getAppsList();return e.forEach(function(r,i){r.app_id==t&&e.splice(i)}),e}},{key:"updateAppsListInStorage",value:function(){var t,e=u(arguments.length>0&&void 0!==arguments[0]?arguments[0]:[]);try{for(e.s();!(t=e.n()).done;){var r=t.value,i=this.storage.getApp(r.app_id);i?(i.from_apps_list=r.from_apps_list,i.permission=r.permission):this.addNewAppToStorage(r)}}catch(n){e.e(n)}finally{e.f()}}},{key:"refreshApps",value:function(){var t=_(l().m(function t(){var e,r,i,n,a,p,s,o,c,f=arguments;return l().w(function(t){for(;;)switch(t.n){case 0:e=f.length>0&&void 0!==f[0]?f[0]:[],r=u(e),t.p=1,r.s();case 2:if((i=r.n()).done){t.n=7;break}if(null==(n=i.value)){t.n=6;break}return t.p=3,t.n=4,this.getAppApi(n);case 4:if(a=t.v){for(a.items_object={},p=0;p<a.items_list.length;p++)for(a.items_object[a.items_list[p].item_id]={},s=0;s<a.items_list[p].fields.length;s++)a.items_object[a.items_list[p].item_id][a.items_list[p].fields[s].field_id]=a.items_list[p].fields[s];this.updateAppInStorage(a),this.pipeService.emit("gh_app_views_update",{app_id:a.app_id},a.views_list)}t.n=6;break;case 5:t.p=5,o=t.v,console.log(o);case 6:t.n=2;break;case 7:t.n=9;break;case 8:t.p=8,c=t.v,r.e(c);case 9:return t.p=9,r.f(),t.f(9);case 10:console.log("Apps refreshed: ",JSON.stringify(e));case 11:return t.a(2)}},t,this,[[3,5],[1,8,9,10]])}));return function(){return t.apply(this,arguments)}}()},{key:"refreshAppsList",value:function(){var t=_(l().m(function t(){var e,r,i;return l().w(function(t){for(;;)switch(t.n){case 0:return e=this.getAppListFromStorage(),t.n=1,this.getAppListApi();case 1:r=t.v,i=r.map(function(t){return s(s({},t),e.find(function(e){return e.app_id===t.app_id}))}),this.updateAppsListInStorage(i),this.pipeService.emit("gh_apps_list_refreshed",{});case 2:return t.a(2)}},t,this)}));return function(){return t.apply(this,arguments)}}()},{key:"getAppsList",value:function(){var t=_(l().m(function t(){var e,r;return l().w(function(t){for(;;)switch(t.n){case 0:if(e=this.getAppListFromStorage(),this.applistReceived){t.n=3;break}return t.n=1,this.getAppListApi();case 1:if(r=t.v){t.n=2;break}return t.a(2,null);case 2:this.updateAppsListInStorage(r),this.applistReceived=!0,e=r,this.getApp(this.storage.getUser().app_init);case 3:return t.a(2,e)}},t,this)}));return function(){return t.apply(this,arguments)}}()},{key:"getAppInfo",value:function(){var t=_(l().m(function t(e){var r;return l().w(function(t){for(;;)switch(t.n){case 0:return t.n=1,this.getAppsList();case 1:return r=t.v,t.a(2,r?r.find(function(t){return t.app_id==e}):null)}},t,this)}));return function(e){return t.apply(this,arguments)}}()},{key:"deleteApp",value:function(){var t=_(l().m(function t(e){return l().w(function(t){for(;;)switch(t.n){case 0:return t.n=1,this.deleteAppApi(e);case 1:return t.a(2,this.deletingAppFromStorage(e))}},t,this)}));return function(e){return t.apply(this,arguments)}}()},{key:"getApp",value:function(){var t=_(l().m(function t(e){var i,n,a,p=this;return l().w(function(t){for(;;)switch(t.n){case 0:if(e){t.n=1;break}return t.a(2,null);case 1:if(!(i=this.getAppFromStorage(e))){t.n=2;break}return t.a(2,i);case 2:if(!this.appRequestCache.has(e)){t.n=3;break}return t.a(2,this.appRequestCache.get(e));case 3:return n=this,a=new Promise(function(){var t=_(l().m(function t(i,a){var o,u,c,f,h,v,_,d;return l().w(function(t){for(;;)switch(t.n){case 0:return t.p=0,t.n=1,p.getAppApi(e);case 1:if((o=t.v)||a(),!o.chunks||!o.chunks.length){t.n=3;break}return t.n=2,n.chunksManager.getChunks(e,o.chunks);case 2:u=t.v,o.items_list=n.util.mergeChunks([].concat(r(u),[o]));case 3:if(c=s({},o),f=[],h=[],Array.isArray(o.items_list))for(v=0;v<o.items_list.length;v++)o.items_list[v].trash?h.push(o.items_list[v]):f.push(o.items_list[v]);if(c.items_list=f,c.trash_items=h,_=[],Array.isArray(o.field_list))for(d=0;d<o.field_list.length;d++)o.field_list[d].trash||_.push(o.field_list[d]);c.field_list=_,i(c),n.saveAppInStorage(c),n.ws.addSubscription(e),t.n=5;break;case 4:t.p=4,t.v,a();case 5:return t.a(2)}},t,null,[[0,4]])}));return function(e,r){return t.apply(this,arguments)}}()),n.appRequestCache.set(e,a),t.a(2,a)}},t,this)}));return function(e){return t.apply(this,arguments)}}()},{key:"updateApp",value:function(){var t=_(l().m(function t(e){var r,i;return l().w(function(t){for(;;)switch(t.n){case 0:if(e.views_list&&e.views_list.length&&e.show){t.n=2;break}return t.n=1,this.getApp(e.app_id);case 1:r=t.v,e.views_list&&e.views_list.length||(e.views_list=r.views_list),void 0===e.show&&(e.show=r.show);case 2:return t.n=3,this.updateAppApi(e);case 3:return i=t.v,this.updateAppFieldsAndViews(i),t.a(2,i)}},t,this)}));return function(e){return t.apply(this,arguments)}}()},{key:"updateAppInfo",value:function(){var t=_(l().m(function t(){var e,r=arguments;return l().w(function(t){for(;;)switch(t.n){case 0:return e=r.length>0&&void 0!==r[0]?r[0]:{},this.pipeService.emit("gh_app_info_update",{app_id:e.app_id},e),t.a(2,this.updateApp(e))}},t,this)}));return function(){return t.apply(this,arguments)}}()},{key:"createNewApp",value:function(){var t=_(l().m(function t(e){var r;return l().w(function(t){for(;;)switch(t.n){case 0:return t.n=1,this.createNewAppApi(e);case 1:return(r=t.v).items_object={},this.addNewAppToStorage(r),t.a(2,r)}},t,this)}));return function(e){return t.apply(this,arguments)}}()},{key:"getAppViews",value:function(){var t=_(l().m(function t(e){var r;return l().w(function(t){for(;;)switch(t.n){case 0:if(!e){t.n=2;break}return t.n=1,this.getApp(e);case 1:return r=t.v,t.a(2,r.views_list);case 2:return t.a(2)}},t,this)}));return function(e){return t.apply(this,arguments)}}()},{key:"clearAppProcessor",value:function(){this.getAppListPromises=null,this.getAppPromises={},this.applistReceived=!1}},{key:"appListeners",value:function(){var e=this;this.pipeService.onRoot("gh_app_get",{},function(){var t=_(l().m(function t(r,i){var n;return l().w(function(t){for(;;)switch(t.n){case 0:if(!i||!i.app_id){t.n=2;break}return t.n=1,e.getApp(i.app_id);case 1:n=t.v,e.pipeService.emit("gh_app_get",i,n);case 2:return t.a(2)}},t)}));return function(e,r){return t.apply(this,arguments)}}()),this.pipeService.onRoot("gh_apps_list_get",{},function(){var t=_(l().m(function t(r,i){var n;return l().w(function(t){for(;;)switch(t.n){case 0:return t.n=1,e.getAppsList();case 1:n=t.v,e.pipeService.emit("gh_apps_list_get",i,n);case 2:return t.a(2)}},t)}));return function(e,r){return t.apply(this,arguments)}}()),this.pipeService.onRoot("gh_delete_app",{},function(){var t=_(l().m(function t(r,i){var n;return l().w(function(t){for(;;)switch(t.n){case 0:return t.n=1,e.deleteApp(i.app_id);case 1:n=t.v,e.pipeService.emit("gh_apps_list_update",{recipient:"all"},n);case 2:return t.a(2)}},t)}));return function(e,r){return t.apply(this,arguments)}}()),this.pipeService.onRoot("gh_app_update",{},function(){var t=_(l().m(function t(r,i){var n,a;return l().w(function(t){for(;;)switch(t.n){case 0:return i.app.items_list=[],i.app.file_list=[],t.n=1,e.updateApp(i.app);case 1:return n=t.v,e.pipeService.emit("gh_app_views_update",{app_id:n.app_id},n.views_list),t.n=2,e.getAppsList();case 2:a=t.v,e.pipeService.emit("gh_apps_list_update",{recipient:"all"},a),n.field_list.forEach(function(t){e.pipeService.emit("gh_model_update",{app_id:n.app_id,field_id:t.field_id},t)});case 3:return t.a(2)}},t)}));return function(e,r){return t.apply(this,arguments)}}()),this.pipeService.onRoot("gh_app_view_get",{},function(){var t=_(l().m(function t(r,i){var n;return l().w(function(t){for(;;)switch(t.n){case 0:if(!i||!i.app_id){t.n=2;break}return t.n=1,e.getApp(i.app_id);case 1:(n=t.v).views_list.forEach(function(t,r){t.view_id==i.view_id&&e.pipeService.emit("gh_app_view_get",i,n.views_list[r])});case 2:return t.a(2)}},t)}));return function(e,r){return t.apply(this,arguments)}}()),this.pipeService.onRoot("gh_app_info_get",{},function(){var t=_(l().m(function t(r,i){var n;return l().w(function(t){for(;;)switch(t.n){case 0:return t.n=1,e.getAppInfo(i.app_id);case 1:(n=t.v)&&e.pipeService.emit("gh_app_info_get",i,n);case 2:return t.a(2)}},t)}));return function(e,r){return t.apply(this,arguments)}}()),this.pipeService.onRoot("gh_app_info_update",{},function(){var t=_(l().m(function t(r,i){var n;return l().w(function(t){for(;;)switch(t.n){case 0:if(!i||!i.app){t.n=2;break}return t.n=1,e.updateAppInfo(i.app);case 1:n=t.v,e.pipeService.emit("gh_app_info_update",{app_id:i.app.app_id},n);case 2:return t.a(2)}},t)}));return function(e,r){return t.apply(this,arguments)}}()),this.pipeService.onRoot("gh_app_create",{},function(){var t=_(l().m(function t(r,i){var n;return l().w(function(t){for(;;)switch(t.n){case 0:return t.n=1,e.createNewApp(i.app);case 1:return t.n=2,e.getAppsList();case 2:n=t.v,e.pipeService.emit("gh_apps_list_update",{recipient:"all"},n);case 3:return t.a(2)}},t)}));return function(e,r){return t.apply(this,arguments)}}()),t.IS_WEB&&this.activateSW&&navigator.serviceWorker.addEventListener("message",function(){var t=_(l().m(function t(r){var i;return l().w(function(t){for(;;)switch(t.n){case 0:if("refresh app"!==r.data.type){t.n=2;break}return t.n=1,e.getApp(r.data.payload.app_id);case 1:(i=t.v)&&e.util.compareAppsItemsLists(i.items_list,r.data.payload.items_list.filter(function(t){return!t.trash}),function(t){var i=t.diff_fields_items,n=t.diff_fields_items_Ids,a=t.diff_items,p=t.newItems,s=t.deletedItems;(a.length||p.length||s.length)&&(e.pipeService.emit("gh_items_update",{app_id:r.data.payload.app_id},r.data.payload.items_list.filter(function(t){return!t.trash})),a.forEach(function(t){return e.pipeService.emit("gh_item_update",{app_id:r.data.payload.app_id,item_id:t.item_id},t)})),n.forEach(function(t){var n=i[t];n&&n.forEach(function(i){e.pipeService.emit("gh_value_update",{app_id:r.data.payload.app_id,item_id:t,field_id:i.field_id},i.field_value)})})}),r.data.payload.items_list=e.util.mergeChunks([i,r.data.payload]),e.saveAppInStorage(r.data.payload);case 2:return t.a(2)}},t)}));return function(e){return t.apply(this,arguments)}}())}}])}();
|
|
266
266
|
},{"../consts.js":"UV2u"}],"UUd3":[function(require,module,exports) {
|
|
267
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ItemProcessor=void 0;var e=require("../utils.js");function t(e){return(t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function r(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,i)}return r}function i(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?r(Object(i),!0).forEach(function(t){n(e,t,i[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):r(Object(i)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))})}return e}function n(e,t,r){return(t=l(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function o(){var e,t,r="function"==typeof Symbol?Symbol:{},i=r.iterator||"@@iterator",n=r.toStringTag||"@@toStringTag";function a(r,i,n,o){var a=i&&i.prototype instanceof c?i:c,p=Object.create(a.prototype);return u(p,"_invoke",function(r,i,n){var o,u,a,c=0,p=n||[],f=!1,l={p:0,n:0,v:e,a:m,f:m.bind(e,4),d:function(t,r){return o=t,u=0,a=e,l.n=r,s}};function m(r,i){for(u=r,a=i,t=0;!f&&c&&!n&&t<p.length;t++){var n,o=p[t],m=l.p,d=o[2];r>3?(n=d===i)&&(a=o[(u=o[4])?5:(u=3,3)],o[4]=o[5]=e):o[0]<=m&&((n=r<2&&m<o[1])?(u=0,l.v=i,l.n=o[1]):m<d&&(n=r<3||o[0]>i||i>d)&&(o[4]=r,o[5]=i,l.n=d,u=0))}if(n||r>1)return s;throw f=!0,i}return function(n,p,d){if(c>1)throw TypeError("Generator is already running");for(f&&1===p&&m(p,d),u=p,a=d;(t=u<2?e:a)||!f;){o||(u?u<3?(u>1&&(l.n=-1),m(u,a)):l.n=a:l.v=a);try{if(c=2,o){if(u||(n="next"),t=o[n]){if(!(t=t.call(o,a)))throw TypeError("iterator result is not an object");if(!t.done)return t;a=t.value,u<2&&(u=0)}else 1===u&&(t=o.return)&&t.call(o),u<2&&(a=TypeError("The iterator does not provide a '"+n+"' method"),u=1);o=e}else if((t=(f=l.n<0)?a:r.call(i,l))!==s)break}catch(t){o=e,u=1,a=t}finally{c=1}}return{value:t,done:f}}}(r,n,o),!0),p}var s={};function c(){}function p(){}function f(){}t=Object.getPrototypeOf;var l=[][i]?t(t([][i]())):(u(t={},i,function(){return this}),t),m=f.prototype=c.prototype=Object.create(l);function d(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,f):(e.__proto__=f,u(e,n,"GeneratorFunction")),e.prototype=Object.create(m),e}return p.prototype=f,u(m,"constructor",f),u(f,"constructor",p),p.displayName="GeneratorFunction",u(f,n,"GeneratorFunction"),u(m),u(m,n,"Generator"),u(m,i,function(){return this}),u(m,"toString",function(){return"[object Generator]"}),(o=function(){return{w:a,m:d}})()}function u(e,t,r,i){var n=Object.defineProperty;try{n({},"",{})}catch(e){n=0}(u=function(e,t,r,i){if(t)n?n(e,t,{value:r,enumerable:!i,configurable:!i,writable:!i}):e[t]=r;else{var o=function(t,r){u(e,t,function(e){return this._invoke(t,r,e)})};o("next",0),o("throw",1),o("return",2)}})(e,t,r,i)}function a(e,t,r,i,n,o,u){try{var a=e[o](u),s=a.value}catch(e){return void r(e)}a.done?t(s):Promise.resolve(s).then(i,n)}function s(e){return function(){var t=this,r=arguments;return new Promise(function(i,n){var o=e.apply(t,r);function u(e){a(o,i,n,u,s,"next",e)}function s(e){a(o,i,n,u,s,"throw",e)}u(void 0)})}}function c(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function p(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,l(i.key),i)}}function f(e,t,r){return t&&p(e.prototype,t),r&&p(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function l(e){var r=m(e,"string");return"symbol"==t(r)?r:r+""}function m(e,r){if("object"!=t(e)||!e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var n=i.call(e,r||"default");if("object"!=t(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===r?String:Number)(e)}var d=exports.ItemProcessor=function(){return f(function e(t,r,i,n,o){c(this,e),this.storage=t,this.pipeService=r,this.req=i,this.appProcessor=n,this.util=o,this.itemListeners()},[{key:"addItemsApi",value:function(){var e=s(o().m(function e(t,r){var i,n;return o().w(function(e){for(;;)switch(e.n){case 0:return e.p=0,e.n=1,this.req.post({url:"/api/items/add",form:{items:JSON.stringify(r),app_id:t}});case 1:return i=e.v,e.a(2,i);case 2:return e.p=2,n=e.v,console.log(n),e.a(2,null)}},e,this,[[0,2]])}));return function(t,r){return e.apply(this,arguments)}}()},{key:"updateItemsApi",value:function(){var e=s(o().m(function e(t,r){var i,n;return o().w(function(e){for(;;)switch(e.n){case 0:return e.p=0,e.n=1,this.req.post({url:"/api/items/update",form:{items:JSON.stringify(r),app_id:t}});case 1:return i=e.v,e.a(2,i);case 2:return e.p=2,n=e.v,console.log(n),e.a(2,null)}},e,this,[[0,2]])}));return function(t,r){return e.apply(this,arguments)}}()},{key:"deleteItemsApi",value:function(e){try{var t=this.req.post({url:"/api/items/delete",form:{items_ids:JSON.stringify(e)}});return t.from_apps_list=!0,t}catch(r){return console.log(r),null}}},{key:"addItemsToStorage",value:function(){var e=s(o().m(function e(t,r){var i,n=this;return o().w(function(e){for(;;)switch(e.n){case 0:return e.n=1,this.appProcessor.getApp(t);case 1:return(i=e.v)&&(r.forEach(function(e){i.items_list.push(e),i.items_object[e.item_id]={};for(var r=0;r<e.fields.length;r++)i.items_object[e.item_id][e.fields[r].field_id]=e.fields[r];n.pipeService.emit("gh_item_update",{app_id:t},[e])}),this.pipeService.emit("gh_items_update",{app_id:t},i.items_list),this.storage.updateApp(i)),e.a(2,i)}},e,this)}));return function(t,r){return e.apply(this,arguments)}}()},{key:"updateItemsInStorage",value:function(){var e=s(o().m(function e(t,r){var i,n=this;return o().w(function(e){for(;;)switch(e.n){case 0:return this.pipeService.emit("gh_items_update",{app_id:t},r),e.n=1,this.appProcessor.getApp(t);case 1:return(i=e.v)&&r&&r.forEach(function(e){var r={app_id:t};n.pipeService.emit("gh_item_update",r,[e]),r.item_id=e.item_id,n.pipeService.emit("gh_item_update",r,e);var o=i.items_list.find(function(t){return t.item_id==e.item_id});o&&e.fields.forEach(function(e){var t=o.fields.find(function(t){return t.field_id==e.field_id});r.field_id=e.field_id,t?t.field_value!=e.field_value&&(t.field_value=e.field_value,i.items_object[o.item_id][t.field_id]=t,n.pipeService.emit("gh_value_update",r,e.field_value)):(o.fields.push(e),i.items_object[o.item_id][e.field_id]=e,n.pipeService.emit("gh_value_update",r,e.field_value))})}),e.a(2,r)}},e,this)}));return function(t,r){return e.apply(this,arguments)}}()},{key:"deleteItemsFromStorage",value:function(){var e=s(o().m(function e(t){var r,i,n=arguments;return o().w(function(e){for(;;)switch(e.n){case 0:return r=n.length>1&&void 0!==n[1]?n[1]:[],e.n=1,this.appProcessor.getApp(t);case 1:(i=e.v)&&(i.items_list=i.items_list.filter(function(e){return!r.find(function(t){return e.item_id==t.item_id})||(delete i.items_object[e.item_id],!1)}),this.pipeService.emit("gh_items_update",{app_id:t},i.items_list),this.storage.updateApp(i));case 2:return e.a(2)}},e,this)}));return function(t){return e.apply(this,arguments)}}()},{key:"getItems",value:function(){var e=s(o().m(function e(t){var r,i=arguments;return o().w(function(e){for(;;)switch(e.n){case 0:return i.length>1&&void 0!==i[1]&&i[1],e.n=1,this.appProcessor.getApp(t);case 1:if(r=e.v){e.n=2;break}return e.a(2,null);case 2:return e.a(2,r.items_list)}},e,this)}));return function(t){return e.apply(this,arguments)}}()},{key:"addNewItems",value:function(){var t=s(o().m(function t(r,n){var u,a;return o().w(function(t){for(;;)switch(t.n){case 0:return u=n.map(function(t){return i(i({},t),{},{fields:(0,e.filterFields)(t.fields)})}),t.n=1,this.addItemsApi(r,u);case 1:return a=t.v,t.n=2,this.addItemsToStorage(r,a);case 2:return this.pipeService.emit("gh_items_add",{app_id:r},a),t.a(2,a)}},t,this)}));return function(e,r){return t.apply(this,arguments)}}()},{key:"updateItems",value:function(){var t=s(o().m(function t(r,n){var u,a;return o().w(function(t){for(;;)switch(t.n){case 0:return u=n.map(function(t){return i(i({},t),{},{fields:(0,e.filterFields)(t.fields)})}),t.n=1,this.updateItemsApi(r,u);case 1:return a=t.v,t.n=2,this.updateItemsInStorage(r,a);case 2:return t.a(2,t.v)}},t,this)}));return function(e,r){return t.apply(this,arguments)}}()},{key:"deleteItems",value:function(){var e=s(o().m(function e(t,r){var i=this;return o().w(function(e){for(;;)switch(e.n){case 0:return e.a(2,this.deleteItemsApi(r).then(function(){var e=s(o().m(function e(r){return o().w(function(e){for(;;)switch(e.n){case 0:return e.n=1,i.deleteItemsFromStorage(t,r);case 1:return e.a(2,e.v)}},e)}));return function(t){return e.apply(this,arguments)}}()))}},e,this)}));return function(t,r){return e.apply(this,arguments)}}()},{key:"restoreItems",value:function(){var e=s(o().m(function e(t,r){var i,n;return o().w(function(e){for(;;)switch(e.n){case 0:return i=r.map(function(e){return{item_id:e,trash:!1}}),e.n=1,this.updateItemsApi(t,i);case 1:return n=e.v,e.n=2,this.updateItemsInStorage(t,n);case 2:return e.a(2,e.v)}},e,this)}));return function(t,r){return e.apply(this,arguments)}}()},{key:"itemListeners",value:function(){var e=this;this.pipeService.onRoot("gh_items_get",{},function(){var t=s(o().m(function t(r,i){var n;return o().w(function(t){for(;;)switch(t.n){case 0:if(!i||!i.app_id){t.n=2;break}return t.n=1,e.getItems(i.app_id);case 1:(n=t.v)?e.pipeService.emit("gh_items_get",i,n):e.pipeService.emit("gh_items_get",i,[]);case 2:return t.a(2)}},t)}));return function(e,r){return t.apply(this,arguments)}}()),this.pipeService.onRoot("gh_items_add",{},function(){var t=s(o().m(function t(r,i){var n;return o().w(function(t){for(;;)switch(t.n){case 0:if(!(i&&i.app_id&&i.items)){t.n=2;break}return t.n=1,e.addNewItems(i.app_id,i.items);case 1:(n=t.v)?e.pipeService.emit("gh_items_add",i,n):e.pipeService.emit("gh_items_add",i,[]);case 2:return t.a(2)}},t)}));return function(e,r){return t.apply(this,arguments)}}()),this.pipeService.onRoot("gh_items_update",{},function(){var t=s(o().m(function t(r,i){var n;return o().w(function(t){for(;;)switch(t.n){case 0:if(!(i&&i.app_id&&i.items)){t.n=2;break}return t.n=1,e.updateItems(i.app_id,i.items);case 1:(n=t.v)?e.pipeService.emit("gh_items_update",i,n):e.pipeService.emit("gh_items_update",i,[]);case 2:return t.a(2)}},t)}));return function(e,r){return t.apply(this,arguments)}}()),this.pipeService.onRoot("gh_item_get",{},function(){var t=s(o().m(function t(r,i){var n,u;return o().w(function(t){for(;;)switch(t.n){case 0:if(!i||!i.app_id){t.n=2;break}return t.n=1,e.getItems(i.app_id);case 1:n=t.v,u=n.find(function(e){return e.item_id==i.item_id}),e.pipeService.emit("gh_item_get",i,u);case 2:return t.a(2)}},t)}));return function(e,r){return t.apply(this,arguments)}}()),this.pipeService.onRoot("gh_filtered_items_get",{},function(){var t=s(o().m(function t(r,i){var n,u;return o().w(function(t){for(;;)switch(t.n){case 0:if(!i||!i.element_app_id){t.n=3;break}return t.n=1,e.getItems(i.element_app_id);case 1:return n=t.v,t.n=2,e.util.getFilteredItems(n,i.filters_list,i.element_app_id,i.app_id,i.item_id,i.field_groupe,i.search,i.search_params);case 2:u=t.v,e.pipeService.emit("gh_filtered_items_get",i,u);case 3:return t.a(2)}},t)}));return function(e,r){return t.apply(this,arguments)}}()),this.pipeService.onRoot("gh_filter_items",{},function(){var t=s(o().m(function t(r,i){var n;return o().w(function(t){for(;;)switch(t.n){case 0:if(!i||!i.items){t.n=2;break}return t.n=1,e.util.getFilteredItems(i.items,i.filters_list,i.element_app_id,i.app_id,i.item_id,i.field_groupe,i.search,i.search_params);case 1:n=t.v,e.pipeService.emit("gh_filter_items",i,n);case 2:return t.a(2)}},t)}));return function(e,r){return t.apply(this,arguments)}}())}}])}();
|
|
267
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ItemProcessor=void 0;var e=require("../utils.js");function t(e){return(t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function r(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,i)}return r}function i(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?r(Object(i),!0).forEach(function(t){n(e,t,i[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):r(Object(i)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))})}return e}function n(e,t,r){return(t=l(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function o(){var e,t,r="function"==typeof Symbol?Symbol:{},i=r.iterator||"@@iterator",n=r.toStringTag||"@@toStringTag";function a(r,i,n,o){var a=i&&i.prototype instanceof c?i:c,p=Object.create(a.prototype);return u(p,"_invoke",function(r,i,n){var o,u,a,c=0,p=n||[],f=!1,l={p:0,n:0,v:e,a:m,f:m.bind(e,4),d:function(t,r){return o=t,u=0,a=e,l.n=r,s}};function m(r,i){for(u=r,a=i,t=0;!f&&c&&!n&&t<p.length;t++){var n,o=p[t],m=l.p,d=o[2];r>3?(n=d===i)&&(a=o[(u=o[4])?5:(u=3,3)],o[4]=o[5]=e):o[0]<=m&&((n=r<2&&m<o[1])?(u=0,l.v=i,l.n=o[1]):m<d&&(n=r<3||o[0]>i||i>d)&&(o[4]=r,o[5]=i,l.n=d,u=0))}if(n||r>1)return s;throw f=!0,i}return function(n,p,d){if(c>1)throw TypeError("Generator is already running");for(f&&1===p&&m(p,d),u=p,a=d;(t=u<2?e:a)||!f;){o||(u?u<3?(u>1&&(l.n=-1),m(u,a)):l.n=a:l.v=a);try{if(c=2,o){if(u||(n="next"),t=o[n]){if(!(t=t.call(o,a)))throw TypeError("iterator result is not an object");if(!t.done)return t;a=t.value,u<2&&(u=0)}else 1===u&&(t=o.return)&&t.call(o),u<2&&(a=TypeError("The iterator does not provide a '"+n+"' method"),u=1);o=e}else if((t=(f=l.n<0)?a:r.call(i,l))!==s)break}catch(t){o=e,u=1,a=t}finally{c=1}}return{value:t,done:f}}}(r,n,o),!0),p}var s={};function c(){}function p(){}function f(){}t=Object.getPrototypeOf;var l=[][i]?t(t([][i]())):(u(t={},i,function(){return this}),t),m=f.prototype=c.prototype=Object.create(l);function d(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,f):(e.__proto__=f,u(e,n,"GeneratorFunction")),e.prototype=Object.create(m),e}return p.prototype=f,u(m,"constructor",f),u(f,"constructor",p),p.displayName="GeneratorFunction",u(f,n,"GeneratorFunction"),u(m),u(m,n,"Generator"),u(m,i,function(){return this}),u(m,"toString",function(){return"[object Generator]"}),(o=function(){return{w:a,m:d}})()}function u(e,t,r,i){var n=Object.defineProperty;try{n({},"",{})}catch(e){n=0}(u=function(e,t,r,i){if(t)n?n(e,t,{value:r,enumerable:!i,configurable:!i,writable:!i}):e[t]=r;else{var o=function(t,r){u(e,t,function(e){return this._invoke(t,r,e)})};o("next",0),o("throw",1),o("return",2)}})(e,t,r,i)}function a(e,t,r,i,n,o,u){try{var a=e[o](u),s=a.value}catch(e){return void r(e)}a.done?t(s):Promise.resolve(s).then(i,n)}function s(e){return function(){var t=this,r=arguments;return new Promise(function(i,n){var o=e.apply(t,r);function u(e){a(o,i,n,u,s,"next",e)}function s(e){a(o,i,n,u,s,"throw",e)}u(void 0)})}}function c(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function p(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,l(i.key),i)}}function f(e,t,r){return t&&p(e.prototype,t),r&&p(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function l(e){var r=m(e,"string");return"symbol"==t(r)?r:r+""}function m(e,r){if("object"!=t(e)||!e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var n=i.call(e,r||"default");if("object"!=t(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===r?String:Number)(e)}var d=exports.ItemProcessor=function(){return f(function e(t,r,i,n,o){c(this,e),this.storage=t,this.pipeService=r,this.req=i,this.appProcessor=n,this.util=o,this.itemListeners()},[{key:"addItemsApi",value:function(){var e=s(o().m(function e(t,r){var i,n;return o().w(function(e){for(;;)switch(e.n){case 0:return e.p=0,e.n=1,this.req.post({url:"/api/items/add",form:{items:JSON.stringify(r),app_id:t}});case 1:return i=e.v,e.a(2,i);case 2:return e.p=2,n=e.v,console.log(n),e.a(2,null)}},e,this,[[0,2]])}));return function(t,r){return e.apply(this,arguments)}}()},{key:"updateItemsApi",value:function(){var e=s(o().m(function e(t,r){var i,n;return o().w(function(e){for(;;)switch(e.n){case 0:return e.p=0,e.n=1,this.req.post({url:"/api/items/update",form:{items:JSON.stringify(r),app_id:t}});case 1:return i=e.v,e.a(2,i);case 2:return e.p=2,n=e.v,console.log(n),e.a(2,null)}},e,this,[[0,2]])}));return function(t,r){return e.apply(this,arguments)}}()},{key:"deleteItemsApi",value:function(e){try{var t=this.req.post({url:"/api/items/delete",form:{items_ids:JSON.stringify(e)}});return t.from_apps_list=!0,t}catch(r){return console.log(r),null}}},{key:"addItemsToStorage",value:function(){var e=s(o().m(function e(t,r){var i,n=this;return o().w(function(e){for(;;)switch(e.n){case 0:return e.n=1,this.appProcessor.getApp(t);case 1:return(i=e.v)&&(r.forEach(function(e){i.items_list.push(e),i.items_object[e.item_id]={};for(var r=0;r<e.fields.length;r++)i.items_object[e.item_id][e.fields[r].field_id]=e.fields[r];n.pipeService.emit("gh_item_update",{app_id:t},[e])}),this.pipeService.emit("gh_items_update",{app_id:t},i.items_list),this.storage.updateApp(i)),e.a(2,i)}},e,this)}));return function(t,r){return e.apply(this,arguments)}}()},{key:"updateItemsInStorage",value:function(){var e=s(o().m(function e(t,r){var i,n=this;return o().w(function(e){for(;;)switch(e.n){case 0:return this.pipeService.emit("gh_items_update",{app_id:t},r),e.n=1,this.appProcessor.getApp(t);case 1:return(i=e.v)&&r&&r.forEach(function(e){var r={app_id:t};n.pipeService.emit("gh_item_update",r,[e]),r.item_id=e.item_id,n.pipeService.emit("gh_item_update",r,e);var o=i.items_list.find(function(t){return t.item_id==e.item_id})||i.trash_items.find(function(t){return t.item_id==e.item_id});o&&(e.fields.forEach(function(e){var t=o.fields.find(function(t){return t.field_id==e.field_id});r.field_id=e.field_id,t?t.field_value!=e.field_value&&(t.field_value=e.field_value,i.items_object[o.item_id][t.field_id]=t,n.pipeService.emit("gh_value_update",r,e.field_value)):(o.fields.push(e),i.items_object[o.item_id][e.field_id]=e,n.pipeService.emit("gh_value_update",r,e.field_value))}),i.items_list.some(function(e){return e.item_id===o.item_id})||(i.trash_items=i.trash_items.filter(function(e){return e.item_id!==o.item_id}),i.items_list.push(o)))}),e.a(2,r)}},e,this)}));return function(t,r){return e.apply(this,arguments)}}()},{key:"deleteItemsFromStorage",value:function(){var e=s(o().m(function e(t){var r,n,u=arguments;return o().w(function(e){for(;;)switch(e.n){case 0:return r=u.length>1&&void 0!==u[1]?u[1]:[],e.n=1,this.appProcessor.getApp(t);case 1:(n=e.v)&&(n.items_list=n.items_list.filter(function(e){return!r.find(function(t){return e.item_id==t.item_id})||(null!=n&&n.trash_items||(n.trash_items=[]),null==n||n.trash_items.push(i(i({},e),{},{trash:!0,last_update:Date.now()})),delete n.items_object[e.item_id],!1)}),this.pipeService.emit("gh_items_update",{app_id:t},n.items_list),this.storage.updateApp(n));case 2:return e.a(2)}},e,this)}));return function(t){return e.apply(this,arguments)}}()},{key:"getItems",value:function(){var e=s(o().m(function e(t){var r,i=arguments;return o().w(function(e){for(;;)switch(e.n){case 0:return i.length>1&&void 0!==i[1]&&i[1],e.n=1,this.appProcessor.getApp(t);case 1:if(r=e.v){e.n=2;break}return e.a(2,null);case 2:return e.a(2,r.items_list)}},e,this)}));return function(t){return e.apply(this,arguments)}}()},{key:"addNewItems",value:function(){var t=s(o().m(function t(r,n){var u,a;return o().w(function(t){for(;;)switch(t.n){case 0:return u=n.map(function(t){return i(i({},t),{},{fields:(0,e.filterFields)(t.fields)})}),t.n=1,this.addItemsApi(r,u);case 1:return a=t.v,t.n=2,this.addItemsToStorage(r,a);case 2:return this.pipeService.emit("gh_items_add",{app_id:r},a),t.a(2,a)}},t,this)}));return function(e,r){return t.apply(this,arguments)}}()},{key:"updateItems",value:function(){var t=s(o().m(function t(r,n){var u,a;return o().w(function(t){for(;;)switch(t.n){case 0:return u=n.map(function(t){return i(i({},t),{},{fields:(0,e.filterFields)(t.fields)})}),t.n=1,this.updateItemsApi(r,u);case 1:return a=t.v,t.n=2,this.updateItemsInStorage(r,a);case 2:return t.a(2,t.v)}},t,this)}));return function(e,r){return t.apply(this,arguments)}}()},{key:"deleteItems",value:function(){var e=s(o().m(function e(t,r){var i=this;return o().w(function(e){for(;;)switch(e.n){case 0:return e.a(2,this.deleteItemsApi(r).then(function(){var e=s(o().m(function e(r){return o().w(function(e){for(;;)switch(e.n){case 0:return e.n=1,i.deleteItemsFromStorage(t,r);case 1:return e.a(2,e.v)}},e)}));return function(t){return e.apply(this,arguments)}}()))}},e,this)}));return function(t,r){return e.apply(this,arguments)}}()},{key:"restoreItems",value:function(){var e=s(o().m(function e(t,r){var i;return o().w(function(e){for(;;)switch(e.n){case 0:return i=r.map(function(e){return{item_id:e,trash:!1}}),e.n=1,this.updateItems(t,i);case 1:return e.a(2,e.v)}},e,this)}));return function(t,r){return e.apply(this,arguments)}}()},{key:"itemListeners",value:function(){var e=this;this.pipeService.onRoot("gh_items_get",{},function(){var t=s(o().m(function t(r,i){var n;return o().w(function(t){for(;;)switch(t.n){case 0:if(!i||!i.app_id){t.n=2;break}return t.n=1,e.getItems(i.app_id);case 1:(n=t.v)?e.pipeService.emit("gh_items_get",i,n):e.pipeService.emit("gh_items_get",i,[]);case 2:return t.a(2)}},t)}));return function(e,r){return t.apply(this,arguments)}}()),this.pipeService.onRoot("gh_items_add",{},function(){var t=s(o().m(function t(r,i){var n;return o().w(function(t){for(;;)switch(t.n){case 0:if(!(i&&i.app_id&&i.items)){t.n=2;break}return t.n=1,e.addNewItems(i.app_id,i.items);case 1:(n=t.v)?e.pipeService.emit("gh_items_add",i,n):e.pipeService.emit("gh_items_add",i,[]);case 2:return t.a(2)}},t)}));return function(e,r){return t.apply(this,arguments)}}()),this.pipeService.onRoot("gh_items_update",{},function(){var t=s(o().m(function t(r,i){var n;return o().w(function(t){for(;;)switch(t.n){case 0:if(!(i&&i.app_id&&i.items)){t.n=2;break}return t.n=1,e.updateItems(i.app_id,i.items);case 1:(n=t.v)?e.pipeService.emit("gh_items_update",i,n):e.pipeService.emit("gh_items_update",i,[]);case 2:return t.a(2)}},t)}));return function(e,r){return t.apply(this,arguments)}}()),this.pipeService.onRoot("gh_item_get",{},function(){var t=s(o().m(function t(r,i){var n,u;return o().w(function(t){for(;;)switch(t.n){case 0:if(!i||!i.app_id){t.n=2;break}return t.n=1,e.getItems(i.app_id);case 1:n=t.v,u=n.find(function(e){return e.item_id==i.item_id}),e.pipeService.emit("gh_item_get",i,u);case 2:return t.a(2)}},t)}));return function(e,r){return t.apply(this,arguments)}}()),this.pipeService.onRoot("gh_filtered_items_get",{},function(){var t=s(o().m(function t(r,i){var n,u;return o().w(function(t){for(;;)switch(t.n){case 0:if(!i||!i.element_app_id){t.n=3;break}return t.n=1,e.getItems(i.element_app_id);case 1:return n=t.v,t.n=2,e.util.getFilteredItems(n,i.filters_list,i.element_app_id,i.app_id,i.item_id,i.field_groupe,i.search,i.search_params);case 2:u=t.v,e.pipeService.emit("gh_filtered_items_get",i,u);case 3:return t.a(2)}},t)}));return function(e,r){return t.apply(this,arguments)}}()),this.pipeService.onRoot("gh_filter_items",{},function(){var t=s(o().m(function t(r,i){var n;return o().w(function(t){for(;;)switch(t.n){case 0:if(!i||!i.items){t.n=2;break}return t.n=1,e.util.getFilteredItems(i.items,i.filters_list,i.element_app_id,i.app_id,i.item_id,i.field_groupe,i.search,i.search_params);case 1:n=t.v,e.pipeService.emit("gh_filter_items",i,n);case 2:return t.a(2)}},t)}));return function(e,r){return t.apply(this,arguments)}}())}}])}();
|
|
268
268
|
},{"../utils.js":"EgeI"}],"PoPF":[function(require,module,exports) {
|
|
269
269
|
"use strict";function e(t){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(t)}function t(){var e,n,i="function"==typeof Symbol?Symbol:{},o=i.iterator||"@@iterator",u=i.toStringTag||"@@toStringTag";function a(t,i,o,u){var a=i&&i.prototype instanceof l?i:l,s=Object.create(a.prototype);return r(s,"_invoke",function(t,r,i){var o,u,a,l=0,s=i||[],f=!1,p={p:0,n:0,v:e,a:d,f:d.bind(e,4),d:function(t,r){return o=t,u=0,a=e,p.n=r,c}};function d(t,r){for(u=t,a=r,n=0;!f&&l&&!i&&n<s.length;n++){var i,o=s[n],d=p.p,v=o[2];t>3?(i=v===r)&&(a=o[(u=o[4])?5:(u=3,3)],o[4]=o[5]=e):o[0]<=d&&((i=t<2&&d<o[1])?(u=0,p.v=r,p.n=o[1]):d<v&&(i=t<3||o[0]>r||r>v)&&(o[4]=t,o[5]=r,p.n=v,u=0))}if(i||t>1)return c;throw f=!0,r}return function(i,s,v){if(l>1)throw TypeError("Generator is already running");for(f&&1===s&&d(s,v),u=s,a=v;(n=u<2?e:a)||!f;){o||(u?u<3?(u>1&&(p.n=-1),d(u,a)):p.n=a:p.v=a);try{if(l=2,o){if(u||(i="next"),n=o[i]){if(!(n=n.call(o,a)))throw TypeError("iterator result is not an object");if(!n.done)return n;a=n.value,u<2&&(u=0)}else 1===u&&(n=o.return)&&n.call(o),u<2&&(a=TypeError("The iterator does not provide a '"+i+"' method"),u=1);o=e}else if((n=(f=p.n<0)?a:t.call(r,p))!==c)break}catch(n){o=e,u=1,a=n}finally{l=1}}return{value:n,done:f}}}(t,o,u),!0),s}var c={};function l(){}function s(){}function f(){}n=Object.getPrototypeOf;var p=[][o]?n(n([][o]())):(r(n={},o,function(){return this}),n),d=f.prototype=l.prototype=Object.create(p);function v(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,f):(e.__proto__=f,r(e,u,"GeneratorFunction")),e.prototype=Object.create(d),e}return s.prototype=f,r(d,"constructor",f),r(f,"constructor",s),s.displayName="GeneratorFunction",r(f,u,"GeneratorFunction"),r(d),r(d,u,"Generator"),r(d,o,function(){return this}),r(d,"toString",function(){return"[object Generator]"}),(t=function(){return{w:a,m:v}})()}function r(e,t,n,i){var o=Object.defineProperty;try{o({},"",{})}catch(e){o=0}(r=function(e,t,n,i){if(t)o?o(e,t,{value:n,enumerable:!i,configurable:!i,writable:!i}):e[t]=n;else{var u=function(t,n){r(e,t,function(e){return this._invoke(t,n,e)})};u("next",0),u("throw",1),u("return",2)}})(e,t,n,i)}function n(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function i(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?n(Object(r),!0).forEach(function(t){o(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):n(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function o(e,t,r){return(t=f(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function u(e,t,r,n,i,o,u){try{var a=e[o](u),c=a.value}catch(e){return void r(e)}a.done?t(c):Promise.resolve(c).then(n,i)}function a(e){return function(){var t=this,r=arguments;return new Promise(function(n,i){var o=e.apply(t,r);function a(e){u(o,n,i,a,c,"next",e)}function c(e){u(o,n,i,a,c,"throw",e)}a(void 0)})}}function c(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function l(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,f(n.key),n)}}function s(e,t,r){return t&&l(e.prototype,t),r&&l(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function f(t){var r=p(t,"string");return"symbol"==e(r)?r:r+""}function p(t,r){if("object"!=e(t)||!t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var i=n.call(t,r||"default");if("object"!=e(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===r?String:Number)(t)}Object.defineProperty(exports,"__esModule",{value:!0}),exports.FieldProcessor=void 0;var d=exports.FieldProcessor=function(){return s(function e(t,r,n,i,o){c(this,e),this.storage=t,this.req=r,this.appProcessor=n,this.itemProcessor=i,this.pipeService=o,this.fieldListeners()},[{key:"deleteFieldApi",value:function(e){return this.req.post({url:"/api/app/delete-field",form:{field_id:e}})}},{key:"updatedFieldApi",value:function(){var e=a(t().m(function e(r){var n,o,u,a=arguments;return t().w(function(e){for(;;)switch(e.n){case 0:return n=a.length>1&&void 0!==a[1]?a[1]:{},e.n=1,this.appProcessor.getApp(r);case 1:return o=e.v,u={app_id:r,app_name:o.app_name,group_id:o.group_id,icon:o.icon,field_list:o.field_list.map(function(e){return e.field_id==n.field_id?i(i({},e),n):e}),views_list:o.views_list},e.a(2,this.appProcessor.updateApp(u))}},e,this)}));return function(t){return e.apply(this,arguments)}}()},{key:"setFieldValueApi",value:function(e,t,r,n){var i=[{item_id:t,fields:[{field_id:r,field_value:n}]}];return this.itemProcessor.updateItems(e,i)}},{key:"deleteFieldInStorage",value:function(e,t){var r=this.storage.getApp(e);return r.field_list=r.field_list.filter(function(e){return e.file_id!=t}),r.items_list=r.items_list.map(function(e){return e.fields=e.fields.filter(function(e){return e.field_id!=t}),e}),this.storage.updateApp(r),!0}},{key:"updateFieldInStorage",value:function(e,t){var r=this.storage.getApp(e);return r.field_list=r.field_list.map(function(e){return e.field_id==t.field_id?i(i({},e),t):e}),this.storage.updateApp(r),t}},{key:"updateFieldValue",value:function(e,t,r,n){var i=this.storage.getApp(e);return i.items_list.forEach(function(e){e.item_id==t&&e.fields.forEach(function(t){t.field_id==r&&(t.field_value=n,i.items_object[e.item_id][t.field_id]=t)})}),this.storage.updateApp(i),n}},{key:"getField",value:function(){var e=a(t().m(function e(r,n){var i,o;return t().w(function(e){for(;;)switch(e.n){case 0:return e.n=1,this.appProcessor.getApp(r);case 1:if(i=e.v){e.n=2;break}return e.a(2,null);case 2:o=0;case 3:if(!(o<i.field_list.length)){e.n=5;break}if(i.field_list[o].field_id!=n){e.n=4;break}return e.a(2,i.field_list[o]);case 4:o++,e.n=3;break;case 5:return e.a(2,null)}},e,this)}));return function(t,r){return e.apply(this,arguments)}}()},{key:"getFieldIdByNameSpace",value:function(){var e=a(t().m(function e(r,n){var i,o;return t().w(function(e){for(;;)switch(e.n){case 0:return e.n=1,this.appProcessor.getApp(r);case 1:if(i=e.v){e.n=2;break}return e.a(2,null);case 2:o=0;case 3:if(!(o<i.field_list.length)){e.n=5;break}if(i.field_list[o].name_space!=n){e.n=4;break}return e.a(2,i.field_list[o].field_id);case 4:o++,e.n=3;break;case 5:return e.a(2,null)}},e,this)}));return function(t,r){return e.apply(this,arguments)}}()},{key:"getFieldModels",value:function(){var e=a(t().m(function e(r){var n;return t().w(function(e){for(;;)switch(e.n){case 0:return e.n=1,this.appProcessor.getApp(r);case 1:if(n=e.v){e.n=2;break}return e.a(2,null);case 2:return e.a(2,n.field_list)}},e,this)}));return function(t){return e.apply(this,arguments)}}()},{key:"updateField",value:function(){var e=a(t().m(function e(r,n){var i;return t().w(function(e){for(;;)switch(e.n){case 0:if(r&&n){e.n=1;break}return e.a(2);case 1:return e.n=2,this.updatedFieldApi(r,n);case 2:return i=e.v,e.a(2,this.updateFieldInStorage(r,i))}},e,this)}));return function(t,r){return e.apply(this,arguments)}}()},{key:"deleteField",value:function(){var e=a(t().m(function e(r,n){return t().w(function(e){for(;;)switch(e.n){case 0:return e.n=1,this.deleteFieldApi(n);case 1:return e.a(2,this.deleteFieldInStorage(r,n))}},e,this)}));return function(t,r){return e.apply(this,arguments)}}()},{key:"getFieldValue",value:function(){var e=a(t().m(function e(r,n,i){var o,u;return t().w(function(e){for(;;)switch(e.n){case 0:return o=null,e.n=1,this.appProcessor.getApp(r);case 1:u=e.v;try{o=u.items_object[n][i].field_value}catch(t){}return e.a(2,o)}},e,this)}));return function(t,r,n){return e.apply(this,arguments)}}()},{key:"setFieldValue",value:function(){var e=a(t().m(function e(r,n,i,o){return t().w(function(e){for(;;)switch(e.n){case 0:if(r&&n&&i){e.n=1;break}return e.a(2);case 1:return e.n=2,this.setFieldValueApi(r,n,i,o);case 2:return e.a(2,this.updateFieldValue(r,n,i,o))}},e,this)}));return function(t,r,n,i){return e.apply(this,arguments)}}()},{key:"fieldListeners",value:function(){var e=this;this.pipeService.onRoot("gh_value_get",{},function(){var r=a(t().m(function r(n,i){var o;return t().w(function(t){for(;;)switch(t.n){case 0:if(!(i.app_id&&i.item_id&&i.field_id)){t.n=2;break}return t.n=1,e.getFieldValue(i.app_id,i.item_id,i.field_id);case 1:o=t.v,e.pipeService.emit("gh_value_get",i,o);case 2:return t.a(2)}},r)}));return function(e,t){return r.apply(this,arguments)}}()),this.pipeService.onRoot("gh_value_set",{},function(){var r=a(t().m(function r(n,i){return t().w(function(t){for(;;)switch(t.n){case 0:i.item_id&&(e.setFieldValue(i.app_id,i.item_id,i.field_id,i.new_value),delete i.new_value);case 1:return t.a(2)}},r)}));return function(e,t){return r.apply(this,arguments)}}()),this.pipeService.onRoot("gh_model_get",{},function(){var r=a(t().m(function r(n,i){var o,u;return t().w(function(t){for(;;)switch(t.n){case 0:return t.p=0,t.n=1,e.getField(i.app_id,i.field_id);case 1:o=t.v,e.pipeService.emit("gh_model_get",i,o),t.n=3;break;case 2:t.p=2,u=t.v,console.log("Field model: ",u);case 3:return t.a(2)}},r,null,[[0,2]])}));return function(e,t){return r.apply(this,arguments)}}()),this.pipeService.onRoot("gh_model_update",{},function(){var r=a(t().m(function r(n,i){var o;return t().w(function(t){for(;;)switch(t.n){case 0:return t.n=1,e.updateField(i.app_id,i.field_model);case 1:o=t.v,e.pipeService.emit("gh_model_update",{app_id:i.app_id,field_id:i.field_id},o);case 2:return t.a(2)}},r)}));return function(e,t){return r.apply(this,arguments)}}()),this.pipeService.onRoot("gh_models_get",{},function(){var r=a(t().m(function r(n,i){var o;return t().w(function(t){for(;;)switch(t.n){case 0:return t.n=1,e.getFieldModels(i.app_id);case 1:o=t.v,e.pipeService.emit("gh_models_get",i,o);case 2:return t.a(2)}},r)}));return function(e,t){return r.apply(this,arguments)}}()),this.pipeService.onRoot("gh_model_delete",{},function(){var r=a(t().m(function r(n,i){var o;return t().w(function(t){for(;;)switch(t.n){case 0:return t.n=1,e.deleteField(i.app_id,i.field_id);case 1:o=t.v,e.pipeService.emit("gh_model_delete",i,o);case 2:return t.a(2)}},r)}));return function(e,t){return r.apply(this,arguments)}}())}}])}();
|
|
270
270
|
},{}],"XUT2":[function(require,module,exports) {
|