biz9-logic 4.0.6 → 4.0.12

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.
Files changed (5) hide show
  1. package/biz9_config +1 -1
  2. package/index.js +201 -92
  3. package/main.js +22 -1
  4. package/package.json +3 -2
  5. package/test.js +35 -10
package/biz9_config CHANGED
@@ -1,4 +1,4 @@
1
- VERSION='4.0.6'
1
+ VERSION='4.1.2'
2
2
  TITLE='BiZ9-Logic';
3
3
  REPO='git@github.com:biz9framework/biz9-logic.git';
4
4
  BRANCH='main';
package/index.js CHANGED
@@ -4,73 +4,189 @@ Author: certifiedcoderz@gmail.com (Certified CoderZ)
4
4
  License GNU General Public License v3.0
5
5
  Description: BiZ9 Framework: Logic-JS
6
6
  */
7
- const { get_new_item_main,get_data_config_main,get_cloud_url_main,get_biz_item_main,get_cloud_filter_obj_main } = require('./main');
8
- const { Log,Test,Str,DateTime } = require('biz9-utility');
9
-
7
+ const moment = require('moment');
8
+ const { get_new_item_main,get_data_config_main,get_cloud_url_main,get_biz_item_main,get_cloud_filter_obj_main,get_new_full_item_main } = require('./main');
9
+ const { Log,Test,Str,DateTime,Number } = require('biz9-utility');
10
10
  class Message {
11
-
12
11
  static SUCCESS="Update Success";
13
12
  static LOGIN_GOOD="Login Success";
14
13
  static LOGIN_BAD="Login Incorrect";
15
14
  }
16
-
17
15
  class TemplateType {
18
-
19
16
  static PRIMARY='primary';
20
17
  static HEADER='header';
21
18
  static NAVIGATION='navigation';
22
19
  static BODY='body';
23
20
  static FOOTER='footer';
24
21
  }
25
-
22
+ class Template{
23
+ static get_test = () =>{
24
+ let template = DataItem.get_new_full_item(
25
+ DataItem.get_new(DataType.TEMPLATE,Number.get_id()),
26
+ DataItem.get_new(DataType.TEMPLATE,0),
27
+ DataItem.get_new(DataType.TEMPLATE,0),
28
+ Field.get_test("Primary"));
29
+ template=Sub_Item.get_list(template,Section.get_test_list(template,template));
30
+ let temp_sub_list = get_test_list(template);
31
+ template = Sub_Item.get_list(template,temp_sub_list);
32
+ function get_test_list(template){
33
+ let template_title_list = ["Header","Navigation","Body","Footer"];
34
+ let template_sub_item_list = [];
35
+ for(let a=0;a<template_title_list.length;a++){
36
+ let template_sub_item = DataItem.get_new_full_item(
37
+ DataItem.get_new(DataType.ITEM,Number.get_id()),
38
+ DataItem.get_new(DataType.TEMPLATE,template.id),
39
+ DataItem.get_new(DataType.TEMPLATE,template.id),
40
+ Field.get_test( template_title_list[a] ));
41
+ template_sub_item = Sub_Item.get_list(template_sub_item,Section.get_test_list(template_sub_item,template));
42
+ template_sub_item_list.push(template_sub_item);
43
+ }
44
+ return template_sub_item_list;
45
+ }
46
+ return template;
47
+ };
48
+ }
49
+ class Page{
50
+ static get_test = (title) =>{
51
+ let page = DataItem.get_new_full_item(
52
+ DataItem.get_new(DataType.PAGE,Number.get_id()),
53
+ DataItem.get_new(DataType.PAGE,Number.get_id()),
54
+ DataItem.get_new(DataType.PAGE,Number.get_id()),
55
+ Field.get_test("Page " + Number.get_id()));
56
+ return Sub_Item.get_list(page,Section.get_test_list(page,page));
57
+ };
58
+ }
59
+ class Product{
60
+ static get_test = () =>{
61
+ let product = DataItem.get_new_full_item(
62
+ DataItem.get_new(DataType.PRODUCT,Number.get_id()),
63
+ DataItem.get_new(DataType.PRODUCT,Number.get_id()),
64
+ DataItem.get_new(DataType.PRODUCT,Number.get_id()),
65
+ Field.get_test("Product " + Number.get_id()));
66
+ product.cost = String(Number.get_id()) + "." + String(Number.get_id());
67
+ product.old_cost = String(Number.get_id()) + "." + String(Number.get_id());
68
+ product.type = "Type "+String(Number.get_id());
69
+ product.sub_type = "Sub Type "+String(Number.get_id());
70
+ product.stock = String(Number.get_id(3-1));
71
+ return Sub_Item.get_list(product,Section.get_test_list(product,product));
72
+ };
73
+ }
74
+ class Service{
75
+ static get_test = () =>{
76
+ let service = DataItem.get_new_full_item(
77
+ DataItem.get_new(DataType.SERVICE,Number.get_id()),
78
+ DataItem.get_new(DataType.SERVICE,Number.get_id()),
79
+ DataItem.get_new(DataType.SERVICE,Number.get_id()),
80
+ Field.get_test("Service " + Number.get_id()));
81
+ service.cost = String(Number.get_id()) + "." + String(Number.get_id());
82
+ service.old_cost = String(Number.get_id()) + "." + String(Number.get_id());
83
+ service.type = "Type "+String(Number.get_id());
84
+ service.sub_type = "Sub Type "+String(Number.get_id());
85
+ service.stock = String(Number.get_id(3-1));
86
+ service.items = Section.get_test_list(service,service);
87
+ return Sub_Item.get_list(service,Section.get_test_list(service,service));
88
+ };
89
+ }
90
+ class Event{
91
+ static get_test = () =>{
92
+ let event = DataItem.get_new_full_item(
93
+ DataItem.get_new(DataType.EVENT,Number.get_id()),
94
+ DataItem.get_new(DataType.EVENT,Number.get_id()),
95
+ DataItem.get_new(DataType.EVENT,Number.get_id()),
96
+ Field.get_test("Event " + Number.get_id()));
97
+ event.cost = String(Number.get_id()) + "." + String(Number.get_id());
98
+ event.old_cost = String(Number.get_id()) + "." + String(Number.get_id());
99
+ event.date = String(String(Number.get_id(2030)) + "-" + String(Number.get_id(13)) + "-" + String(Number.get_id(30))).trim();
100
+ event.time = String(Number.get_id(24)) + ":" + String(Number.get_id(59));
101
+ event.website = "Website "+String(Number.get_id());
102
+ event.location = "Location "+String(Number.get_id());
103
+ event.meeting_link = "Meeting Link "+String(Number.get_id());
104
+ event.stock = String(Number.get_id(3-1));
105
+ event.items = Section.get_test_list(event,event);
106
+ return Sub_Item.get_list(event,Section.get_test_list(event,event));
107
+ };
108
+ }
109
+ class Section{
110
+ static get_test_list = (parent_item,top_item) =>{
111
+ let items = get_item_section_list(parent_item,top_item);
112
+ function get_item_section_list(parent_item,top_item){
113
+ let new_list = [];
114
+ for(let a=1;a<20;a++){
115
+ let item_title = "Section " + String(a);
116
+ let item = DataItem.get_new(
117
+ DataType.ITEM,Number.get_id(), {
118
+ top_id:top_item.id,
119
+ top_data_type:top_item.data_type,
120
+ parent_id:parent_item.id,
121
+ parent_data_type:parent_item.data_type,
122
+ title:item_title,
123
+ title_url:Str.get_title_url(item_title),
124
+ sub_note:"Sub Note "+String(Number.get_id()),
125
+ note:"Note "+String(Number.get_id()),
126
+ date_create:new moment().toISOString(),
127
+ date_save:new moment().toISOString(),
128
+ }
129
+ );
130
+ for(let b=1;b<20;b++){
131
+ item['value_'+String(b)] = 'Section '+ String(a) + ' value ' + String(b);
132
+ }
133
+ new_list.push(item);
134
+ }
135
+ return new_list;
136
+ }
137
+ return items;
138
+ };
139
+ }
140
+ class Field{
141
+ static get_test = (title) =>{
142
+ let item = {
143
+ date_create:new moment().toISOString(),
144
+ date_save:new moment().toISOString(),
145
+ title:title,
146
+ setting_visible:"1",
147
+ title_url:Str.get_title_url(title),
148
+ sub_note : "Sub Note "+String(Number.get_id()),
149
+ note : "Note "+String(Number.get_id())
150
+ }
151
+ for(let b = 1;b<20;b++){
152
+ item['value_'+String(b)] = 'value ' + String(b);
153
+ }
154
+ return item;
155
+ }
156
+ }
26
157
  class FieldType {
27
-
28
158
  static APP_ID='app_id';
29
159
  static ID='id';
30
160
  static DATA_TYPE='data_type';
31
-
32
161
  static PARENT_ID='parent_id';
33
162
  static PARENT_DATA_TYPE='parent_data_type';
34
-
35
163
  static PHOTO_DATA='photo_data';
36
-
37
164
  static TOP_ID='top_id';
38
165
  static TOP_DATA_TYPE='top_data_type';
39
-
40
166
  static DATE_CREATE='date_create';
41
167
  static DATE_SAVE='date_save';
42
-
43
168
  static TITLE='title';
44
169
  static TITLE_URL='title_url';
45
-
46
170
  static SETTING_DELETE_PROTECTION='setting_delete_protection';
47
171
  static SETTING_VISIBLE='setting_visible';
48
172
  static SETTING_ORDER='setting_order';
49
-
50
173
  static SOURCE='source';
51
-
52
174
  static SOURCE_ID='source_id';
53
175
  static SOURCE_DATA_TYPE='source_data_type';
54
-
55
176
  static SOURCE_PARENT_ID='source_parent_id';
56
177
  static SOURCE_PARENT_DATA_TYPE='source_parent_data_type';
57
-
58
178
  static SOURCE_TOP_ID='source_top_id';
59
179
  static SOURCE_TOP_DATA_TYPE='source_top_data_type';
60
-
61
180
  static DATE_CREATE='date_create';
62
181
  static DATE_SAVE='date_save';
63
182
  }
64
-
65
183
  class PageType {
66
-
67
184
  static HOME='home';
68
185
  static ABOUT='about';
69
186
  static CONTACT='contact';
70
187
  static SERVICE='service';
71
188
  static PRODUCT='product';
72
189
  static TEAM='team';
73
-
74
190
  static SECTION_1='section_1';
75
191
  static SECTION_2='section_2';
76
192
  static SECTION_3='section_2';
@@ -90,7 +206,6 @@ class PageType {
90
206
  static SECTION_17='section_17';
91
207
  static SECTION_18='section_18';
92
208
  static SECTION_19='section_19';
93
-
94
209
  static VALUE_1='value_1';
95
210
  static VALUE_2='value_2';
96
211
  static VALUE_3='value_2';
@@ -111,9 +226,7 @@ class PageType {
111
226
  static VALUE_18='value_18';
112
227
  static VALUE_19='value_19';
113
228
  }
114
-
115
229
  class DataType {
116
-
117
230
  static get_title = (data_type) => {
118
231
  if(!data_type){
119
232
  return "";
@@ -121,7 +234,6 @@ class DataType {
121
234
  return String(Str.get_title(data_type.replaceAll('_',' ').replaceAll('dt','').replace('biz',''))).trim();
122
235
  }
123
236
  }
124
-
125
237
  static ADMIN='admin_biz';
126
238
  static BLANK='blank_biz';
127
239
  static BUSINESS='business_biz';
@@ -146,7 +258,35 @@ class DataType {
146
258
  static VIDEO='video_biz';
147
259
  }
148
260
  class Business {
149
-
261
+ static get_new = () =>{
262
+ return DataItem.get_new(DataType.BUSINESS,Number.get_id(),
263
+ {
264
+ title:"",
265
+ email:"",
266
+ phone:"",
267
+ address_1:"",
268
+ address_2:"",
269
+ city:"",
270
+ state:"",
271
+ zip:"",
272
+ });
273
+ };
274
+ static get_test = () =>{
275
+ let item = DataItem.get_new(DataType.BUSINESS,Number.get_id());
276
+ let city_list = ["Blank","Miami","Atlanta","Chicago","Seattle","New York City"];
277
+ let state_list = ["Blank","Georgia","New York","Illinois","Washington","Flordia"];
278
+ item.title = "Title "+Number.get_id();
279
+ item.date_create=new moment().toISOString();
280
+ item.date_save=new moment().toISOString();
281
+ item.email="ceo@business.com";
282
+ item.phone="123-456-"+Number.get_id();
283
+ item.address_1=Number.get_id()+" Apple St.";
284
+ item.address_2="PO Box "+Number.get_id();
285
+ item.city=city_list[Number.get_id(city_list.length-1)];
286
+ item.state=state_list[Number.get_id(state_list.length-1)];
287
+ item.zip="123"+Number.get_id();
288
+ return item;
289
+ };
150
290
  static get_full_address(business){
151
291
  if(!business.address_1){
152
292
  business.address_1 = "";
@@ -160,21 +300,19 @@ class Business {
160
300
  if(!business.state){
161
301
  business.state = "";
162
302
  }
163
-
164
303
  return business.address_1 + " "+ business.address_2 + " " + business.city + " " + business.state + " " + business.zip;
165
304
  }
166
305
  }
167
-
168
306
  class DataItem {
169
-
170
307
  static get_new = (data_type,id,options) => {
171
308
  return get_new_item_main(data_type,id,options);
172
309
  };
173
-
310
+ static get_new_full_item = (item,parent_item,top_item,options) => {
311
+ return get_new_full_item_main(item,parent_item,top_item,options);
312
+ };
174
313
  static get_biz = (biz9_config,item,options)=>{
175
314
  return get_biz_item_main(biz9_config,item,options);
176
315
  }
177
-
178
316
  static get_biz_by_list = (biz9_config,list,options)=>{
179
317
  let r_list = [];
180
318
  for(let a=0;a<list.length;a++){
@@ -182,120 +320,93 @@ class DataItem {
182
320
  }
183
321
  return r_list;
184
322
  }
185
-
186
323
  }
187
324
  class BiZ_Url {
188
-
189
325
  static get_item=(biz9_config,data_type,id)=>{
190
326
  let action_url="main/biz_item/get/"+data_type+"/"+id ;
191
327
  return get_cloud_url_main(biz9_config.APP_ID,biz9_config.URL,action_url,null);
192
328
  };
193
-
194
329
  static delete_item=(biz9_config,data_type,id)=>{
195
330
  let action_url= "main/biz_item/delete/"+data_type+"/"+id ;
196
331
  return get_cloud_url_main(biz9_config.APP_ID,biz9_config.URL,action_url,null);
197
332
  };
198
-
199
333
  static get_full_item=(biz9_config,data_type,id)=>{
200
334
  let action_url= "main/biz_item/get_full/"+data_type+"/"+id;
201
335
  return get_cloud_url_main(biz9_config.APP_ID,biz9_config.URL,action_url,null);
202
336
  };
203
-
204
337
  static get_page=(biz9_config,title_url)=>{
205
338
  let action_url= "main/biz_item/get_page/"+title_url;
206
339
  return get_cloud_url_main(biz9_config.APP_ID,biz9_config.URL,action_url,null);
207
340
  };
208
-
209
341
  static get_template=(biz9_config,title_url)=>{
210
342
  let action_url= "main/biz_item/get_template/"+title_url;
211
343
  return get_cloud_url_main(biz9_config.APP_ID,biz9_config.URL,action_url,null);
212
344
  };
213
-
214
345
  }
215
-
216
- class Url {
217
-
346
+ class Url{
218
347
  static get = (biz9_config,action_url,params)=>{
219
348
  return get_cloud_url_main(biz9_config.APP_ID,biz9_config.URL,action_url,params);
220
349
  }
221
-
222
350
  static connect = (biz9_config) => {
223
351
  let action_url= "main/test/connect/";
224
352
  return get_cloud_url_main(biz9_config.APP_ID,biz9_config.URL,action_url,null);
225
353
  };
226
-
227
354
  static upload_file = (biz9_config,data_type,id) => {
228
355
  let action_url= "main/crud/update/"+data_type + "/" + id;
229
356
  return get_cloud_url_main(biz9_config.APP_ID,biz9_config.URL,action_url,null);
230
357
  };
231
-
232
358
  static update_item = (biz9_config,data_type,id) => {
233
359
  let action_url= "main/crud/update/"+data_type + "/" + id;
234
360
  return get_cloud_url_main(biz9_config.APP_ID,biz9_config.URL,action_url,null);
235
361
  };
236
-
237
362
  static update_delete_cache_item = (biz9_config,data_type,id) => {
238
363
  let action_url= "main/crud/update_delete_cache/"+data_type + "/" + id;
239
364
  return get_cloud_url_main(biz9_config.APP_ID,biz9_config.URL,action_url,null);
240
365
  };
241
-
242
366
  static get_item = (biz9_config,data_type,id) => {
243
367
  let action_url= "main/crud/get/"+data_type + "/" + id;
244
368
  return get_cloud_url_main(biz9_config.APP_ID,biz9_config.URL,action_url,null);
245
369
  };
246
-
247
370
  static delete_item = (biz9_config,data_type,id) => {
248
371
  let action_url= "main/crud/delete/"+data_type + "/" + id;
249
372
  return get_cloud_url_main(biz9_config.APP_ID,biz9_config.URL,action_url,null);
250
373
  };
251
-
252
374
  static copy_item = (biz9_config,data_type,id) => {
253
375
  let action_url= "main/biz_item/copy/"+data_type + "/" + id;
254
376
  return get_cloud_url_main(biz9_config.APP_ID,biz9_config.URL,action_url,null);
255
377
  };
256
-
257
378
  static get_list = (biz9_config,data_type) => {
258
379
  let action_url= "main/crud/get_list/"+data_type;
259
380
  return get_cloud_url_main(biz9_config.APP_ID,biz9_config.URL,action_url,null);
260
381
  };
261
-
262
382
  static update_list = (biz9_config,data_type) => {
263
383
  let action_url= "main/crud/update_list/"+data_type;
264
384
  return get_cloud_url_main(biz9_config.APP_ID,biz9_config.URL,action_url,null);
265
385
  };
266
-
267
386
  static delete_list = (biz9_config,data_type) => {
268
387
  let action_url= "main/crud/delete_list/"+data_type;
269
388
  return get_cloud_url_main(biz9_config.APP_ID,biz9_config.URL,action_url,null);
270
389
  };
271
-
272
390
  static delete_biz_item = (biz9_config,data_type,id) => {
273
391
  let action_url= "main/biz_item/delete/"+data_type + "/" + id;
274
392
  return get_cloud_url_main(biz9_config.APP_ID,biz9_config.URL,action_url,null);
275
393
  };
276
-
277
394
  static get_biz_list = (biz9_config,data_type) => {
278
395
  let action_url= "main/biz_item/get_list/"+data_type;
279
396
  return get_cloud_url_main(biz9_config.APP_ID,biz9_config.URL,action_url,null);
280
397
  };
281
-
282
398
  static delete_biz_list = (biz9_config,data_type) => {
283
399
  let action_url= "main/biz_item/delete_list/"+data_type;
284
400
  return get_cloud_url_main(biz9_config.APP_ID,biz9_config.URL,action_url,null);
285
401
  };
286
-
287
402
  }
288
-
289
403
  class Obj {
290
-
291
404
  static get_filter = (biz9_config,data_type,filter,sort_by,page_current,page_size)=>{
292
405
  return get_cloud_filter_obj_main(data_type,filter,sort_by,page_current,page_size);
293
406
  }
294
-
295
407
  };
296
408
 
297
409
  class Cat {
298
-
299
410
  static get_category_drop_down_list_by_list = (cat_list) => {
300
411
  let category_list = [];
301
412
  for(let a=0;a<cat_list.length;a++){
@@ -303,7 +414,6 @@ class Cat {
303
414
  }
304
415
  return category_list;
305
416
  };
306
-
307
417
  static get_category_list = () => {
308
418
  return [
309
419
  { value: DataType.BLOG_POST, label: "Blog Posts" },
@@ -315,7 +425,6 @@ class Cat {
315
425
  { value: DataType.TEMPLATE, label: "Template" }
316
426
  ];
317
427
  };
318
-
319
428
  static get_title_by_type = (data_type) => {
320
429
  switch (data_type) {
321
430
  case DataType.EVENT:
@@ -355,10 +464,8 @@ class Cat {
355
464
  return "Blank";
356
465
  }
357
466
  }
358
-
359
467
  };
360
468
  class CMS {
361
-
362
469
  static Tab_Edit_Title_General = 'general';
363
470
  static Tab_Edit_Title_Photo = 'photo';
364
471
  static Tab_Edit_Title_List = 'list';
@@ -368,7 +475,6 @@ class CMS {
368
475
  static Tab_Edit_Title_Video = 'video';
369
476
  static Tab_Edit_Title_Note = 'note';
370
477
  static get_new_query_item_by_item = (item) => {
371
-
372
478
  return {
373
479
  id: item.id ? item.id : 0,
374
480
  data_type:item.data_type ? item.data_type : DataType.BLANK,
@@ -380,7 +486,6 @@ class CMS {
380
486
  top_data_type:item.top_data_type ? item.top_data_type : DataType.BLANK
381
487
  }
382
488
  };
383
-
384
489
  static get_new_query_item = (item,parent_item,top_item) => {
385
490
  return {
386
491
  id: item.id ? item.id : 0,
@@ -392,35 +497,27 @@ class CMS {
392
497
  top_data_type:top_item.data_type ? top_item.data_type : DataType.BLANK
393
498
  }
394
499
  };
395
-
396
500
  static get_query_itemz_by_query = (item) => {
397
501
  return [];
398
502
  };
399
-
400
503
  static get_query_item_by_page = (item) => {
401
504
  return { id:item.id ? item.id : 0, data_type:item.data_type ? item.data_type : DataType.BLANK };
402
505
  };
403
-
404
506
  static get_query_parent_item_by_page = (parent_item) => {
405
507
  return { id:parent_item.id ? parent_item.id : 0, data_type:parent_item.data_type ? parent_item.data_type : DataType.BLANK };
406
508
  };
407
-
408
509
  static get_query_top_item_by_page = (top_item) => {
409
510
  return { id:top_item.id ? top_item.id : 0, data_type:top_item.data_type ? top_item.data_type : DataType.BLANK };
410
511
  };
411
-
412
512
  static get_query_item_by_query = (query) => {
413
513
  return { id:query.get('id') ? query.get('id') : 0, data_type:query.get('data_type') ? query.get('data_type') : DataType.BLANK } ;
414
514
  };
415
-
416
515
  static get_query_parent_item_by_query = (query) => {
417
516
  return { id:query.get('parent_id') ? query.get('parent_id') : 0, data_type:query.get('parent_data_type') ? query.get('parent_data_type') : DataType.BLANK } ;
418
-
419
517
  };
420
518
  static get_query_top_item_by_query = (query) => {
421
519
  return { id:query.get('top_id') ? query.get('top_id') : 0, data_type:query.get('top_data_type') ? query.get('top_data_type') : DataType.BLANK } ;
422
520
  };
423
-
424
521
  static get_sub_page_title = (title) => {
425
522
  switch(title)
426
523
  {
@@ -450,7 +547,6 @@ class CMS {
450
547
  break;
451
548
  }
452
549
  }
453
-
454
550
  static get_page_url = (url,tab_title,item,parent_item,top_item,parms) => {
455
551
  let r_url="?tab_title="+tab_title
456
552
  +"&id="+item.id
@@ -469,10 +565,8 @@ class CMS {
469
565
  }
470
566
  return url+r_url;
471
567
  }
472
-
473
568
  }
474
569
  class Stock {
475
-
476
570
  static get_event_stock_list = () => {
477
571
  const r_list=
478
572
  [
@@ -483,7 +577,6 @@ class Stock {
483
577
  ];
484
578
  return r_list;
485
579
  };
486
-
487
580
  static get_event_stock_by_value = (stock_val) => {
488
581
  switch(stock_val)
489
582
  {
@@ -501,7 +594,6 @@ class Stock {
501
594
  break;
502
595
  }
503
596
  };
504
-
505
597
  static get_service_stock_list = () => {
506
598
  const r_list=
507
599
  [
@@ -511,7 +603,6 @@ class Stock {
511
603
  ];
512
604
  return r_list;
513
605
  };
514
-
515
606
  static get_service_stock_by_value = (stock_val) => {
516
607
  switch(stock_val)
517
608
  {
@@ -526,7 +617,6 @@ class Stock {
526
617
  break;
527
618
  }
528
619
  };
529
-
530
620
  static get_product_stock_list = () => {
531
621
  const r_list=
532
622
  [
@@ -537,7 +627,6 @@ class Stock {
537
627
  ];
538
628
  return r_list;
539
629
  };
540
-
541
630
  static get_product_stock_by_value = (stock_val) => {
542
631
  switch(stock_val)
543
632
  {
@@ -558,10 +647,8 @@ class Stock {
558
647
  break;
559
648
  }
560
649
  };
561
-
562
650
  }
563
651
  class Schedule {
564
-
565
652
  static get_start_date_time = (item) =>{
566
653
  if(!item.date){
567
654
  item.date = new Date();
@@ -574,7 +661,6 @@ class Schedule {
574
661
  item.start_date_time = DateTime.get_full_date_time_by_date_time(item.date,item.time);
575
662
  return item;
576
663
  }
577
-
578
664
  static get_start_date_time_by_list = (list) =>{
579
665
  for(let a=0;a<list.length;a++){
580
666
  if(!list[a].date){
@@ -589,32 +675,48 @@ class Schedule {
589
675
  }
590
676
  return list;
591
677
  }
592
-
593
678
  };
594
679
  class Storage {
595
-
596
680
  static KEY_ADMIN="key_admin";
597
681
  static KEY_USER="key_user";
598
682
  static KEY_BUSINESS="key_business";
599
683
  static KEY_GUEST="key_guest";
600
684
  static KEY_APP_ID="key_app_id";
601
-
602
685
  static get = (window,key) => {
603
686
  return JSON.parse(window.localStorage.getItem(key));
604
687
  }
605
-
606
688
  static set = (window,key,obj) => {
607
689
  window.localStorage.setItem(key,JSON.stringify(obj));
608
690
  }
609
-
610
691
  static remove = (window,key) =>{
611
692
  window.localStorage.removeItem(key);
612
693
  }
613
-
614
694
  static clear = (window) =>{
615
695
  window.localStorage.clear();
616
696
  }
617
-
697
+ }
698
+ class Sub_Item{
699
+ static get_list = (parent_item, item_list) => {
700
+ parent_item.items = [];
701
+ for(let a=0; a<item_list.length; a++){
702
+ let item_title_url = Str.get_title_url(item_list[a].title);
703
+ let new_item = item_list[a];
704
+ new_item.items = [];
705
+ item_list[item_title_url] = item_list[a];
706
+ for(let b=0;b<item_list.length;b++){
707
+ let sub_item_title_url = Str.get_title_url(item_list[b].title);
708
+ if(item_list[a].id == item_list[b].parent_id){
709
+ let sub_item = item_list[b];
710
+ new_item.items.push(sub_item);
711
+ item_list[a][sub_item_title_url] = sub_item;
712
+ item_list[a][sub_item_title_url].items = [];
713
+ }
714
+ }
715
+ parent_item[item_title_url] = item_list[a];
716
+ parent_item.items.push(item_list[a]);
717
+ }
718
+ return parent_item;
719
+ }
618
720
  }
619
721
  module.exports = {
620
722
  BiZ_Url,
@@ -624,11 +726,18 @@ module.exports = {
624
726
  DataItem,
625
727
  DataType,
626
728
  FieldType,
729
+ Event,
627
730
  Message,
628
731
  Obj,
732
+ Page,
629
733
  PageType,
734
+ Product,
630
735
  TemplateType,
736
+ Template,
631
737
  Url,
738
+ Section,
739
+ Service,
740
+ Sub_Item,
632
741
  Storage,
633
742
  Schedule,
634
743
  Stock,
package/main.js CHANGED
@@ -26,6 +26,26 @@ const get_new_item_main = (data_type,id,options) => {
26
26
  }
27
27
  return item;
28
28
  }
29
+ const get_new_full_item_main = (org_item,parent_item,top_item,options) => {
30
+ if(!options){
31
+ options = {};
32
+ }
33
+ let item = {
34
+ data_type:org_item.data_type,
35
+ id:org_item.id,
36
+ parent_id:parent_item.id,
37
+ parent_data_type:parent_item.data_type,
38
+ top_id:top_item.id,
39
+ top_data_type:top_item.data_type
40
+ };
41
+ if(options){
42
+ for (const key in options) {
43
+ item[key] = options[key];
44
+ }
45
+ }
46
+ return item;
47
+ }
48
+
29
49
  const get_cloud_url_main = (app_id,domain_url,action_url,params) =>{
30
50
  if(!params){
31
51
  params='';
@@ -127,5 +147,6 @@ module.exports = {
127
147
  get_cloud_url_main,
128
148
  get_cloud_filter_obj_main,
129
149
  get_title_url_main,
130
- get_biz_item_main
150
+ get_biz_item_main,
151
+ get_new_full_item_main
131
152
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "biz9-logic",
3
- "version": "4.0.6",
3
+ "version": "4.0.12",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"
@@ -11,7 +11,8 @@
11
11
  "async-series": "^0.0.1",
12
12
  "biz9-scriptz": "^5.6.6",
13
13
  "biz9-utility": "^3.5.9",
14
- "jest": "^29.7.0"
14
+ "jest": "^29.7.0",
15
+ "moment": "^2.30.1"
15
16
  },
16
17
  "repository": {
17
18
  "type": "git",
package/test.js CHANGED
@@ -1,6 +1,6 @@
1
1
  const path = require('path');
2
2
  const series = require('async-series');
3
- const {DataItem,DataType,Url,Obj,BiZ_Url,Cat,Stock,Schedule,Storage,Business} = require('./');
3
+ const {DataItem,DataType,Url,Obj,BiZ_Url,Cat,Stock,Schedule,Storage,Business,Product,Service,Event,Template,Page} = require('./');
4
4
  const {Log,Test,Number} = require('biz9-utility');
5
5
  const {Scriptz}= require('biz9-scriptz');
6
6
 
@@ -29,6 +29,39 @@ describe("connect", () => {
29
29
  it("_connect", () => {
30
30
  series([
31
31
 
32
+ function(call) {
33
+ console.log('CONNECT-START');
34
+ //let biz9_config = Scriptz.get_biz9_config({biz9_config_file:path.resolve('../../biz9_config')});
35
+ //let cloud_url = Url.connect(biz9_config);
36
+ //console.log(Business.get_test()); // get_business_test
37
+ //console.log(Page.get_test()); // get_page_test
38
+ console.log(Event.get_test());
39
+ //console.log(Template.get_test());
40
+ //console.log(Product.get_test());
41
+ //let product = Product.get_test();
42
+ //console.log(product.section_1);
43
+ //get page
44
+
45
+ //Log.w('product',product);
46
+ //Log.w('product_section_1',product.section_1);
47
+
48
+ //console.log(Product.get_test());
49
+ //Log.w('connect_url',cloud_url);
50
+ console.log('CONNECT-SUCCESS');
51
+ //call()
52
+ },
53
+
54
+ function(call) {
55
+ console.log('GET-FULL-ITEM-START');
56
+ let item = DataItem.get_new(DataType.BLANK,0);
57
+ let parent_item = DataItem.get_new(DataType.BLOG_POST,2);
58
+ let top_item = DataItem.get_new(DataType.PRODUCT,3);
59
+ let options={title:'cool_bean'};
60
+ console.log(DataItem.get_new_full_item(item,parent_item,top_item,options));
61
+ console.log('GET-FULL-ITEM-END');
62
+ //call();
63
+ },
64
+
32
65
  function(call) {
33
66
  console.log('GET-BiZ-Url-Item-Get-Item-START');
34
67
  let biz9_config = Scriptz.get_biz9_config({biz9_config_file:path.resolve('../../biz9_config')});
@@ -200,15 +233,7 @@ describe("connect", () => {
200
233
  console.log('GET-URL-SUCCESS');
201
234
  call()
202
235
  },
203
- function(call) {
204
- console.log('CONNECT-START');
205
- let biz9_config = Scriptz.get_biz9_config({biz9_config_file:path.resolve('../../biz9_config')});
206
- let cloud_url = Url.connect(biz9_config);
207
- Log.w('connect_url',cloud_url);
208
- console.log('CONNECT-SUCCESS');
209
- call()
210
- },
211
- function(call) {
236
+ function(call) {
212
237
  console.log('GET_URL-UPDATE-ITEM-START');
213
238
  let biz9_config = Scriptz.get_biz9_config({biz9_config_file:path.resolve('../../biz9_config')});
214
239
  let data_type = 'dt_blank';