biz9-logic 4.0.5 → 4.0.11

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