biz9-logic 10.0.25 → 10.0.35

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 (4) hide show
  1. package/biz9_config +1 -1
  2. package/index.js +462 -508
  3. package/package.json +1 -1
  4. package/test.js +20 -12
package/index.js CHANGED
@@ -35,50 +35,46 @@ class Message {
35
35
  class Item_Logic {
36
36
  static get_new = (title,data_type,option)=>{
37
37
  option = option ? option : {};
38
- const item = DataItem.get_new(data_type,0,{title:title,title_url:Str.get_title_url(title),setting_visible:"1"});
38
+ const item = Data_Logic.get_new(data_type,0,{title:title,title_url:Str.get_title_url(title),setting_visible:"1"});
39
39
  return item;
40
40
  };
41
41
  static copy = (data_type,item)=>{
42
- let copy_item = DataItem.get_new(data_type,0);
42
+ let copy_item = Data_Logic.get_new(data_type,0);
43
43
  const keys = Object.keys(item);
44
- keys.forEach(key => {
45
- if(
46
- key!=Type.FIELD_ID&&
47
- key!=Type.FIELD_SOURCE&&
48
- key!=Type.FIELD_TITLE&&
49
- key!=Type.FIELD_TITLE_URL&&
50
- key!=Type.FIELD_DATE_CREATE&&
51
- key!=Type.FIELD_DATE_SAVE&&
52
- key!=Type.TITLE_OBJ&&
53
- key!=Type.TITLE_USER&&
54
- key!=Type.TITLE_GROUP&&
55
- key!=Type.TITLE_ITEM&&
56
- !Obj.check_is_array(item[key])&&
57
- Obj.check_is_value(item[key])
44
+ keys.forEach(key => {
45
+ if(
46
+ key!=Type.FIELD_ID&&
47
+ key!=Type.FIELD_SOURCE&&
48
+ key!=Type.FIELD_TITLE&&
49
+ key!=Type.FIELD_TITLE_URL&&
50
+ key!=Type.FIELD_DATE_CREATE&&
51
+ key!=Type.FIELD_DATE_SAVE&&
52
+ key!=Type.TITLE_OBJ&&
53
+ key!=Type.TITLE_USER&&
54
+ key!=Type.TITLE_GROUP&&
55
+ key!=Type.TITLE_ITEM&&
56
+ !Obj.check_is_array(item[key])&&
57
+ Obj.check_is_value(item[key])
58
58
  ){
59
- copy_item[key]=item[key];
60
- }
61
- });
59
+ copy_item[key]=item[key];
60
+ }
61
+ });
62
62
  return copy_item;
63
63
  };
64
64
  static bind_child_parent_obj = (child_obj,parent_obj)=>{
65
65
  for(const prop in parent_obj) {
66
66
  child_obj['parent_'+prop] = parent_obj[prop];
67
67
  }
68
- return child_obj;
68
+ return child_obj;
69
69
  };
70
70
  static get_test = (title,data_type,id,option)=>{
71
- data_type = data_type ? data_type : DataType.BLANK;
71
+ data_type = data_type ? data_type : Type.DATA_BLANK;
72
72
  id = id ? id : 0;
73
73
  option = Field_Logic.get_option(data_type,option?option:{});
74
- let item = DataItem.get_new(data_type,0,Field_Logic.get_test(title,option));
75
- if(option.get_item){
76
- item.items = Sub_Item_Logic.get_test_items(item,item,option);
77
- item = Sub_Item_Logic.bind_parent_child_items(item,item.items);
78
- }
74
+ let item = Data_Logic.get_new(data_type,0,Field_Logic.get_test(title,option));
79
75
  return item;
80
76
  }
81
- static get_test_items = (data_type,option) =>{
77
+ static get_test_items = (data_type,option) =>{
82
78
  option = Field_Logic.get_option(data_type,option?option:{});
83
79
  let items = [];
84
80
  for(let a=0;a<parseInt(option.item_count)+1;a++){
@@ -147,63 +143,6 @@ class Title {
147
143
  static DESCRIPTION='Description';
148
144
  static TYPE='Type';
149
145
  }
150
- class Demo_Logic {
151
- static get_new_type = (title,option) => {
152
- title = !Str.check_is_null(title)?title:Title.TYPE+" " +Num.get_id(999);
153
- option = option ? option : {get_category:false,category_count:6,categorys:'',category_data_type:DataType.BLANK,get_item:false,items:'',item_data_type:DataType.BLANK,item_count:6}; const item = Item_Logic.get_new(title,DataType.TYPE); //category
154
- if(option.get_category){
155
- item.categorys = [];
156
- let category_titles = [];
157
- if(option.categorys){
158
- category_titles = option.categorys.split(',');
159
- option.category_count = category_titles.length;
160
- }else{
161
- if(!option.category_count){
162
- option.category_count = 1;
163
- }
164
- for(let a = 1;a<parseInt(option.category_count)+1;a++){
165
- category_titles.push(Title.CATEGORY+" "+a);
166
- }
167
- }
168
- category_titles.forEach(cat_item => {
169
- item.categorys.push(Category_Logic.get_new(cat_item,item.title,option.category_data_type));
170
- });
171
- }
172
- //item
173
- if(option.get_item){
174
- let full_items = [];
175
-
176
- let item_titles = [];
177
- if(option.items){
178
- item_titles = option.items.split(',');
179
- option.item_count = item_titles.length;
180
- }else{
181
- for(let b = 1;b<parseInt(option.item_count)+1;b++){
182
- item_titles.push(title+" " +Type.get_title(item.categorys[Num.get_id(option.category_count)].category)+" "+ b);
183
- }
184
- }
185
- for(const child_item_title of item_titles){
186
- const cat_item = item.categorys[Num.get_id(option.category_count)];
187
- if(!cat_item.items){
188
- cat_item.items = [];
189
- }
190
- let child_item = Item_Logic.get_new(child_item_title,option.item_data_type);
191
- if(option.item_data_type == DataType.PRODUCT){
192
- child_item.cost = Num.get_id(9000);
193
- child_item.old_cost = Num.get_id(90000);
194
- }
195
- child_item.type = cat_item.type;
196
- child_item.tag = "Tag "+ Num.get_id() + ", Tag "+Num.get_id() + ", Tag "+ Num.get_id();
197
- child_item.category = cat_item.title;
198
- child_item.description =Title.DESCRIPTION+" "+ String(Num.get_id());
199
- child_item.note = Field_Logic.get_test_note(),
200
- cat_item.items.push(child_item);
201
- full_items.push(child_item);
202
- }
203
- }
204
- return item;
205
- };
206
- }
207
146
  class Type {
208
147
  //app_status
209
148
  static APP_ENV_TEST='test';
@@ -214,24 +153,58 @@ class Type {
214
153
  static APP_LINK_TYPE_APPLE_STORE='apple_store';
215
154
  static APP_LINK_TYPE_CMS='cms';
216
155
 
156
+ //data
157
+ static DATA_APP='app_biz';
158
+ static DATA_BLANK='blank_biz';
159
+ static DATA_BLOG_POST='blog_post_biz';
160
+ static DATA_CART_ITEM="cart_item_biz";
161
+ static DATA_CART="cart_biz";
162
+ static DATA_CART_ITEM="cart_item_biz";
163
+ static DATA_CART_SUB_ITEM="cart_sub_item_biz";
164
+ static DATA_CATEGORY='category_biz';
165
+ static DATA_CUSTOM_FIELD='custom_field_biz';
166
+ static DATA_CONTENT='content_biz';
167
+ static DATA_EVENT='event_biz';
168
+ static DATA_GROUP='group_biz';
169
+ static DATA_FAQ='faq_biz';
170
+ static DATA_FAVORITE='favorite_biz';
171
+ static DATA_FILE='file_biz';
172
+ static DATA_GALLERY='gallery_biz';
173
+ static DATA_IMAGE='image_biz';
174
+ static DATA_LINK='link_biz';
175
+ static DATA_ORDER="order_biz";
176
+ static DATA_ORDER_ITEM="order_item_biz";
177
+ static DATA_ORDER_SUB_ITEM="order_sub_item_biz";
178
+ static DATA_ORDER_PAYMENT="order_payment_biz";
179
+ static DATA_PRODUCT='product_biz';
180
+ static DATA_PAGE='page_biz';
181
+ static DATA_REVIEW='review_biz';
182
+ static DATA_SERVICE='service_biz';
183
+ static DATA_SECURITY='security_biz';
184
+ static DATA_STAT='stat_biz';
185
+ static DATA_TEMPLATE='template_biz';
186
+ static DATA_TYPE='type_biz';
187
+ static DATA_USER='user_biz';
188
+ static DATA_VIDEO='video_biz';
189
+
217
190
  //field
218
- static FIELD_AUTHOR = 'author';
219
- static FIELD_CATEGORY = 'category';
220
- static FIELD_CATEGORY_TYPE = 'category_type';
221
- static FIELD_COST = 'cost';
191
+ static FIELD_AUTHOR = 'author';
192
+ static FIELD_CATEGORY = 'category';
193
+ static FIELD_CATEGORY_TYPE = 'category_type';
194
+ static FIELD_COST = 'cost';
222
195
  static FIELD_DATA_TYPE='data_type';
223
196
  static FIELD_DATE_CREATE='date_create';
224
197
  static FIELD_DATE_SAVE='date_save';
225
198
  static FIELD_DATE = 'date';
226
- static FIELD_DESCRIPTION = 'description';
227
- static FIELD_EDIT_LOCATION = 'edit_location';
199
+ static FIELD_DESCRIPTION = 'description';
200
+ static FIELD_EDIT_LOCATION = 'edit_location';
228
201
  static FIELD_ID='id';
229
- static FIELD_IMAGE_FILENAME = 'image_filename';
230
- static FIELD_LOCATION = 'location';
231
- static FIELD_MEETING_LINK = 'meeting_link';
232
- static FIELD_NOTE = 'note';
233
- static FIELD_OLD_COST = 'old_cost';
234
- static FIELD_PARAM = 'param';
202
+ static FIELD_IMAGE_FILENAME = 'image_filename';
203
+ static FIELD_LOCATION = 'location';
204
+ static FIELD_MEETING_LINK = 'meeting_link';
205
+ static FIELD_NOTE = 'note';
206
+ static FIELD_OLD_COST = 'old_cost';
207
+ static FIELD_PARAM = 'param';
235
208
  static FIELD_PARENT_DATA_TYPE='parent_data_type';
236
209
  static FIELD_PARENT_ID='parent_id';
237
210
  static FIELD_ROLE = 'role';
@@ -240,28 +213,28 @@ class Type {
240
213
  static FIELD_SOURCE_KEY='source_key';
241
214
  static FIELD_SOURCE_ID='source_id';
242
215
  static FIELD_SOURCE_PARENT_ID='source_parent_id';
243
- static FIELD_SETTING_VISIBLE = 'setting_visible';
244
- static FIELD_SETTING_DELETE_PROTECTION = 'setting_delete_protection';
245
- static FIELD_SETTING_SORT_TYPE = 'setting_delete_sort_type';
246
- static FIELD_STOCK = 'stock';
247
- static FIELD_TAG = 'tag';
248
- static FIELD_TIME = 'time';
249
- static FIELD_TITLE='title';
216
+ static FIELD_SETTING_VISIBLE = 'setting_visible';
217
+ static FIELD_SETTING_DELETE_PROTECTION = 'setting_delete_protection';
218
+ static FIELD_SETTING_SORT_TYPE = 'setting_delete_sort_type';
219
+ static FIELD_STOCK = 'stock';
220
+ static FIELD_TAG = 'tag';
221
+ static FIELD_TIME = 'time';
222
+ static FIELD_TITLE='title';
250
223
  static FIELD_TITLE_URL='title_url';
251
- static FIELD_TYPE = 'type';
252
- static FIELD_URL = 'url';
253
- static FIELD_USER_CITY = 'city';
254
- static FIELD_USER_COUNTRY = 'country';
255
- static FIELD_USER_EMAIL = 'email';
256
- static FIELD_USER_FIRST_NAME = 'first_name';
257
- static FIELD_USER_GENDER = 'gender';
224
+ static FIELD_TYPE = 'type';
225
+ static FIELD_URL = 'url';
226
+ static FIELD_USER_CITY = 'city';
227
+ static FIELD_USER_COUNTRY = 'country';
228
+ static FIELD_USER_EMAIL = 'email';
229
+ static FIELD_USER_FIRST_NAME = 'first_name';
230
+ static FIELD_USER_GENDER = 'gender';
258
231
  static FIELD_USER_ID='user_id';
259
- static FIELD_USER_LAST_NAME = 'last_name';
260
- static FIELD_USER_USERNAME = 'username';
261
- static FIELD_USER_PASSWORD = 'password';
262
- static FIELD_USER_STATE = 'state';
263
- static FIELD_VALUE = 'value';
264
- static FIELD_WEBSITE = 'website';
232
+ static FIELD_USER_LAST_NAME = 'last_name';
233
+ static FIELD_USER_USERNAME = 'username';
234
+ static FIELD_USER_PASSWORD = 'password';
235
+ static FIELD_USER_STATE = 'state';
236
+ static FIELD_VALUE = 'value';
237
+ static FIELD_WEBSITE = 'website';
265
238
  //title
266
239
  static TITLE_BLANK='blank';
267
240
  static TITLE_CART_ITEMS='cart_items';
@@ -271,8 +244,9 @@ class Type {
271
244
  static TITLE_COUNT='count';
272
245
  static TITLE_GROUP='group';
273
246
  static TITLE_N_A='n/a';
247
+ static TITLE_IMAGES='images';
274
248
  static TITLE_ITEMS='items';
275
- static TITLE_OBJ='obj';
249
+ static TITLE_ONE='one';
276
250
  static TITLE_ORDER_ITEMS='order_items';
277
251
  static TITLE_ORDER_SUB_ITEMS='order_sub_items';
278
252
  static TITLE_PARENT_ITEM='parent_item';
@@ -423,30 +397,30 @@ class Type {
423
397
  };
424
398
  static get_data_types = () =>{
425
399
  return [
426
- {title:Type.get_title(DataType.BLOG_POST),type:DataType.BLOG_POST,label:Type.get_title(DataType.BLOG_POST),value:DataType.BLOG_POST},
427
- {title:Type.get_title(DataType.CATEGORY),type:DataType.CATEGORY,label:Type.get_title(DataType.CATEGORY),value:DataType.CATEGORY},
428
- {title:Type.get_title(DataType.CONTENT),type:DataType.CONTENT,label:Type.get_title(DataType.CONTENT),value:DataType.CONTENT},
429
- {title:Type.get_title(DataType.EVENT),type:DataType.EVENT,label:Type.get_title(DataType.EVENT),value:DataType.EVENT},
430
- {title:Type.get_title(DataType.FAQ),type:DataType.FAQ,label:Type.get_title(DataType.FAQ),value:DataType.FAQ},
431
- {title:Type.get_title(DataType.GALLERY),type:DataType.GALLERY,label:Type.get_title(DataType.GALLERY),value:DataType.GALLERY},
432
- {title:Type.get_title(DataType.USER),type:DataType.USER,label:Type.get_title(DataType.USER),value:DataType.USER},
433
- {title:Type.get_title(DataType.PAGE),type:DataType.PAGE,label:Type.get_title(DataType.PAGE),value:DataType.PAGE},
434
- {title:Type.get_title(DataType.PRODUCT),type:DataType.PRODUCT,label:Type.get_title(DataType.PRODUCT),value:DataType.PRODUCT},
435
- {title:Type.get_title(DataType.SERVICE),type:DataType.SERVICE,label:Type.get_title(DataType.SERVICE),value:DataType.SERVICE}
400
+ {title:Type.get_title(Type.DATA_BLOG_POST),type:Type.DATA_BLOG_POST,label:Type.get_title(Type.DATA_BLOG_POST),value:Type.DATA_BLOG_POST},
401
+ {title:Type.get_title(Type.DATA_CATEGORY),type:Type.DATA_CATEGORY,label:Type.get_title(Type.DATA_CATEGORY),value:Type.DATA_CATEGORY},
402
+ {title:Type.get_title(Type.DATA_CONTENT),type:Type.DATA_CONTENT,label:Type.get_title(Type.DATA_CONTENT),value:Type.DATA_CONTENT},
403
+ {title:Type.get_title(Type.DATA_EVENT),type:Type.DATA_EVENT,label:Type.get_title(Type.DATA_EVENT),value:Type.DATA_EVENT},
404
+ {title:Type.get_title(Type.DATA_FAQ),type:Type.DATA_FAQ,label:Type.get_title(Type.DATA_FAQ),value:Type.DATA_FAQ},
405
+ {title:Type.get_title(Type.DATA_GALLERY),type:Type.DATA_GALLERY,label:Type.get_title(Type.DATA_GALLERY),value:Type.DATA_GALLERY},
406
+ {title:Type.get_title(Type.DATA_USER),type:Type.DATA_USER,label:Type.get_title(Type.DATA_USER),value:Type.DATA_USER},
407
+ {title:Type.get_title(Type.DATA_PAGE),type:Type.DATA_PAGE,label:Type.get_title(Type.DATA_PAGE),value:Type.DATA_PAGE},
408
+ {title:Type.get_title(Type.DATA_PRODUCT),type:Type.DATA_PRODUCT,label:Type.get_title(Type.DATA_PRODUCT),value:Type.DATA_PRODUCT},
409
+ {title:Type.get_title(Type.DATA_SERVICE),type:Type.DATA_SERVICE,label:Type.get_title(Type.DATA_SERVICE),value:Type.DATA_SERVICE}
436
410
  ]
437
411
  };
438
412
  static get_types = () =>{
439
413
  return [
440
- {title:Type.get_title(DataType.BLOG_POST),type:DataType.BLOG_POST,label:Type.get_title(DataType.BLOG_POST),value:DataType.BLOG_POST},
441
- {title:Type.get_title(DataType.CATEGORY),type:DataType.CATEGORY,label:Type.get_title(DataType.CATEGORY),value:DataType.CATEGORY},
442
- {title:Type.get_title(DataType.CONTENT),type:DataType.CONTENT,label:Type.get_title(DataType.CONTENT),value:DataType.CONTENT},
443
- {title:Type.get_title(DataType.EVENT),type:DataType.EVENT,label:Type.get_title(DataType.EVENT),value:DataType.EVENT},
444
- {title:Type.get_title(DataType.GALLERY),type:DataType.GALLERY,label:Type.get_title(DataType.GALLERY),value:DataType.GALLERY},
445
- {title:Type.get_title(DataType.USER),type:DataType.USER,label:Type.get_title(DataType.USER),value:DataType.USER},
446
- {title:Type.get_title(DataType.PAGE),type:DataType.PAGE,label:Type.get_title(DataType.PAGE),value:DataType.PAGE},
447
- {title:Type.get_title(DataType.PRODUCT),type:DataType.PRODUCT,label:Type.get_title(DataType.PRODUCT),value:DataType.PRODUCT},
448
- {title:Type.get_title(DataType.SERVICE),type:DataType.SERVICE,label:Type.get_title(DataType.SERVICE),value:DataType.SERVICE},
449
- {title:Type.get_title(DataType.TYPE),type:DataType.TYPE,label:Type.get_title(DataType.TYPE),value:DataType.TYPE}
414
+ {title:Type.get_title(Type.DATA_BLOG_POST),type:Type.DATA_BLOG_POST,label:Type.get_title(Type.DATA_BLOG_POST),value:Type.DATA_BLOG_POST},
415
+ {title:Type.get_title(Type.DATA_CATEGORY),type:Type.DATA_CATEGORY,label:Type.get_title(Type.DATA_CATEGORY),value:Type.DATA_CATEGORY},
416
+ {title:Type.get_title(Type.DATA_CONTENT),type:Type.DATA_CONTENT,label:Type.get_title(Type.DATA_CONTENT),value:Type.DATA_CONTENT},
417
+ {title:Type.get_title(Type.DATA_EVENT),type:Type.DATA_EVENT,label:Type.get_title(Type.DATA_EVENT),value:Type.DATA_EVENT},
418
+ {title:Type.get_title(Type.DATA_GALLERY),type:Type.DATA_GALLERY,label:Type.get_title(Type.DATA_GALLERY),value:Type.DATA_GALLERY},
419
+ {title:Type.get_title(Type.DATA_USER),type:Type.DATA_USER,label:Type.get_title(Type.DATA_USER),value:Type.DATA_USER},
420
+ {title:Type.get_title(Type.DATA_PAGE),type:Type.DATA_PAGE,label:Type.get_title(Type.DATA_PAGE),value:Type.DATA_PAGE},
421
+ {title:Type.get_title(Type.DATA_PRODUCT),type:Type.DATA_PRODUCT,label:Type.get_title(Type.DATA_PRODUCT),value:Type.DATA_PRODUCT},
422
+ {title:Type.get_title(Type.DATA_SERVICE),type:Type.DATA_SERVICE,label:Type.get_title(Type.DATA_SERVICE),value:Type.DATA_SERVICE},
423
+ {title:Type.get_title(Type.DATA_TYPE),type:Type.DATA_TYPE,label:Type.get_title(Type.DATA_TYPE),value:Type.DATA_TYPE}
450
424
  ]
451
425
  };
452
426
  static get_app_environments = () =>{
@@ -466,13 +440,13 @@ class Type {
466
440
  //9_get_title
467
441
  static get_title = (type,option)=>{
468
442
  /* option
469
- * get_lowercase = ex. true,false / def. false
470
- * get_plural = ex. true,false / def. false
471
- * get_url = ex. true,false / def. false
472
- */
443
+ * lowercase = ex. true,false / def. false
444
+ * plural = ex. true,false / def. false
445
+ * url = ex. true,false / def. false
446
+ */
473
447
  type = type?type:"";
474
448
  let r_type = "";
475
- option = option ? option : {get_lowercase:false,get_plural:false,get_url:false};
449
+ option = option ? option : {lowercase:false,plural:false,url:false};
476
450
  switch(type){
477
451
  case Type.STAT_CART:
478
452
  r_type = "Cart";
@@ -574,66 +548,64 @@ class Type {
574
548
  case Type.ORDER_PAYMENT_METHOD_CASH:
575
549
  case Type.ORDER_PAYMENT_METHOD_OTHER:
576
550
  case Type.ORDER_PAYMENT_METHOD_TEST:
577
- case DataType.APP:
578
- case DataType.BLANK:
579
- case DataType.BLOG_POST:
580
- case DataType.CART:
581
- case DataType.CART_ITEM:
582
- case DataType.CART_SUB_ITEM:
583
- case DataType.CATEGORY:
584
- case DataType.CUSTOM_FIELD:
585
- case DataType.CONTENT:
586
- case DataType.EVENT:
587
- case DataType.FAQ:
588
- case DataType.FAVORITE:
589
- case DataType.FILE:
590
- case DataType.GALLERY:
591
- case DataType.GROUP:
592
- case DataType.ITEM_MAP:
593
- case DataType.ITEM:
594
- case DataType.LINK:
595
- case DataType.ORDER:
596
- case DataType.ORDER_ITEM:
597
- case DataType.ORDER_SUB_ITEM:
598
- case DataType.ORDER_PAYMENT:
599
- case DataType.PRODUCT:
600
- case DataType.IMAGE:
601
- case DataType.PAGE:
602
- case DataType.REVIEW:
603
- case DataType.SERVICE:
604
- case DataType.SECURITY:
605
- case DataType.STAT:
606
- case DataType.TEMPLATE:
607
- case DataType.TYPE:
608
- case DataType.USER:
609
- case DataType.VIDEO:
610
- r_type = String(Str.get_title(type.replaceAll('_',' ').replaceAll('dt','').replace('biz',''))).trim();
611
- break;
551
+ case Type.DATA_APP:
552
+ case Type.DATA_BLANK:
553
+ case Type.DATA_BLOG_POST:
554
+ case Type.DATA_CART:
555
+ case Type.DATA_CART_ITEM:
556
+ case Type.DATA_CART_SUB_ITEM:
557
+ case Type.DATA_CATEGORY:
558
+ case Type.DATA_CUSTOM_FIELD:
559
+ case Type.DATA_CONTENT:
560
+ case Type.DATA_EVENT:
561
+ case Type.DATA_FAQ:
562
+ case Type.DATA_FAVORITE:
563
+ case Type.DATA_FILE:
564
+ case Type.DATA_GALLERY:
565
+ case Type.DATA_GROUP:
566
+ case Type.DATA_LINK:
567
+ case Type.DATA_ORDER:
568
+ case Type.DATA_ORDER_ITEM:
569
+ case Type.DATA_ORDER_SUB_ITEM:
570
+ case Type.DATA_ORDER_PAYMENT:
571
+ case Type.DATA_PRODUCT:
572
+ case Type.DATA_IMAGE:
573
+ case Type.DATA_PAGE:
574
+ case Type.DATA_REVIEW:
575
+ case Type.DATA_SERVICE:
576
+ case Type.DATA_SECURITY:
577
+ case Type.DATA_STAT:
578
+ case Type.DATA_TEMPLATE:
579
+ case Type.DATA_TYPE:
580
+ case Type.DATA_USER:
581
+ case Type.DATA_VIDEO:
582
+ r_type = String(Str.get_title(type.replaceAll('_',' ').replaceAll('dt','').replace('biz',''))).trim();
583
+ break;
612
584
  default:
613
585
  r_type = "N/A";
614
586
  break;
615
587
  }
616
- if(option.get_plural){
617
- r_type = r_type + 's';
618
- }
619
- if(option.get_lowercase){
620
- r_type = r_type.toLowerCase();
621
- }
622
- if(option.get_url){
623
- r_type = r_type.replace(" ","_").toLowerCase();
624
- }
625
- return r_type;
588
+ if(option.plural){
589
+ r_type = r_type + 's';
590
+ }
591
+ if(option.lowercase){
592
+ r_type = r_type.toLowerCase();
593
+ }
594
+ if(option.url){
595
+ r_type = r_type.replace(" ","_").toLowerCase();
596
+ }
597
+ return r_type;
626
598
  };
627
599
  static get_type_title = (data_type) => {
628
600
  return String(data_type.replaceAll('_',' ').replaceAll('dt','').replace('biz','')).trim();
629
601
  };
630
602
  }
631
603
  class Stat_Logic {
632
- static get_new = (parent_data_type,parent_id,stat_type,user_id,post_data) => {
633
- let new_stat = DataItem.get_new(DataType.STAT,0,
604
+ static get_new = (parent_data_type,parent_id,type,user_id,post_data) => {
605
+ let new_stat = Data_Logic.get_new(Type.DATA_STAT,0,
634
606
  {
635
607
  user_id:user_id,
636
- stat_type:stat_type,
608
+ type:type,
637
609
  parent_data_type:parent_data_type,
638
610
  parent_id:parent_id
639
611
  });
@@ -645,38 +617,34 @@ class Stat_Logic {
645
617
  static filter_stat = (post_data) =>{
646
618
  let filter_stat = {};
647
619
  for(const prop in post_data) {
648
- const value = post_data[prop];
620
+ const value = post_data[prop];
649
621
  if (!Array.isArray(value)
650
622
  && prop != Type.FIELD_SOURCE
651
623
  && prop != Type.FIELD_DATE_CREATE
652
624
  && prop != Type.FIELD_DATE_SAVE
653
625
  && prop != Type.FIELD_DATA_TYPE
654
- && prop != Type.TITLE_CART_ITEMS
626
+ && prop != Type.TITLE_CART_ITEMS
655
627
  && prop != Type.TITLE_CART_SUB_ITEMS
656
- && prop != Type.TITLE_ORDER_ITEMS
628
+ && prop != Type.TITLE_ORDER_ITEMS
657
629
  && prop != Type.TITLE_ORDER_SUB_ITEMS
658
- && prop != Type.FIELD_SOURCE
630
+ && prop != Type.FIELD_SOURCE
659
631
  && prop != Type.FIELD_SOURCE_ID
660
632
  && prop != Type.FIELD_ID) {
661
- filter_stat[prop] = post_data[prop];
662
- }
663
- }
633
+ filter_stat[prop] = post_data[prop];
634
+ }
635
+ }
664
636
  return filter_stat;
665
637
  }
666
638
  }
667
639
  class Page_Logic {
668
- static get_test = (title,option) =>{
640
+ static get_test = (title,option) =>{
669
641
  [title,option] = Field_Logic.get_option_title(title,option);
670
- option = Field_Logic.get_option(DataType.PAGE,option?option:{});
671
- let page = DataItem.get_new(DataType.PAGE,0,Field_Logic.get_test(title,option));
672
- if(option.get_section){
673
- page.items = Sub_Item_Logic.get_test_sections(page,page,option);
674
- page = Sub_Item_Logic.bind_parent_child_items(page,page.items);
675
- }
642
+ option = Field_Logic.get_option(Type.DATA_PAGE,option?option:{});
643
+ let page = Data_Logic.get_new(Type.DATA_PAGE,0,Field_Logic.get_test(title,option));
676
644
  return page;
677
645
  };
678
646
  static get_test_items = (option) =>{
679
- option = Field_Logic.get_option(DataType.PAGE,option?option:{});
647
+ option = Field_Logic.get_option(Type.DATA_PAGE,option?option:{});
680
648
  let items = [];
681
649
  for(let a=0;a<parseInt(option.page_count)+1;a++){
682
650
  items.push(Page_Logic.get_test( "Page " +parseInt(a+1)? !option.get_blank : "",option));
@@ -687,7 +655,7 @@ static get_test = (title,option) =>{
687
655
  class Order_Logic {
688
656
  static get_new = (cart,option) => {
689
657
  option = option?option:{get_payment_plan:false,payment_plan:Title.ORDER_PAYMENT_PLAN_1};
690
- let order = DataItem.get_new(DataType.ORDER,0,{
658
+ let order = Data_Logic.get_new(Type.DATA_ORDER,0,{
691
659
  order_number:Title.ORDER_NUMBER + Num.get_id(99999),
692
660
  parent_data_type:cart.parent_data_type,
693
661
  user_id:cart.user_id,
@@ -700,18 +668,18 @@ class Order_Logic {
700
668
  if(!Str.check_is_null(cart[key])
701
669
  && key != Type.FIELD_ID && key != Type.FIELD_DATA_TYPE
702
670
  && key != Type.TITLE_PARENT_ITEM && key != Type.TITLE_USER
703
- && key != Type.TITLE_CART_ITEMS && key != Type.TITLE_CART_SUB_ITEMS
704
- && key != Type.TITLE_ORDER_ITEMS && key != Type.TITLE_ORDER_SUB_ITEMS
705
- && key != Type.FIELD_SOURCE && key != Type.FIELD_SOURCE_ID
706
- && key != Type.FIELD_DATE_CREATE && key != Type.FIELD_DATE_SAVE){
671
+ && key != Type.TITLE_CART_ITEMS && key != Type.TITLE_CART_SUB_ITEMS
672
+ && key != Type.TITLE_ORDER_ITEMS && key != Type.TITLE_ORDER_SUB_ITEMS
673
+ && key != Type.FIELD_SOURCE && key != Type.FIELD_SOURCE_ID
674
+ && key != Type.FIELD_DATE_CREATE && key != Type.FIELD_DATE_SAVE){
707
675
  order[key] = cart[key];
708
- }
709
- }
676
+ }
677
+ }
710
678
  if(option.get_payment_plan){
711
679
  order.payment_plan = option.payment_plan;
712
680
  }
713
681
  cart.cart_items.forEach(cart_item => {
714
- let order_item = DataItem.get_new(DataType.ORDER_ITEM,0,{
682
+ let order_item = Data_Logic.get_new(Type.DATA_ORDER_ITEM,0,{
715
683
  order_number:order.order_number,
716
684
  parent_data_type:cart_item.parent_data_type,
717
685
  parent_id:cart_item.parent_id,
@@ -720,19 +688,19 @@ class Order_Logic {
720
688
  cost:cart_item.cost?cart_item.cost:0,
721
689
  order_sub_items:[]
722
690
  });
723
- for(const key in cart_item){
724
- if(!Str.check_is_null(cart_item[key])
725
- && key != Type.FIELD_ID && key != Type.FIELD_DATA_TYPE
726
- && key != Type.TITLE_PARENT_ITEM && key != Type.TITLE_USER
727
- && key != Type.TITLE_CART_ITEMS && key != Type.TITLE_CART_SUB_ITEMS
728
- && key != Type.TITLE_ORDER_ITEMS && key != Type.TITLE_ORDER_SUB_ITEMS
729
- && key != Type.FIELD_SOURCE && key != Type.FIELD_SOURCE_ID
730
- && key != Type.FIELD_DATE_CREATE && key != Type.FIELD_DATE_SAVE){
691
+ for(const key in cart_item){
692
+ if(!Str.check_is_null(cart_item[key])
693
+ && key != Type.FIELD_ID && key != Type.FIELD_DATA_TYPE
694
+ && key != Type.TITLE_PARENT_ITEM && key != Type.TITLE_USER
695
+ && key != Type.TITLE_CART_ITEMS && key != Type.TITLE_CART_SUB_ITEMS
696
+ && key != Type.TITLE_ORDER_ITEMS && key != Type.TITLE_ORDER_SUB_ITEMS
697
+ && key != Type.FIELD_SOURCE && key != Type.FIELD_SOURCE_ID
698
+ && key != Type.FIELD_DATE_CREATE && key != Type.FIELD_DATE_SAVE){
731
699
  order_item[key] = cart_item[key];
732
- }
733
- }
700
+ }
701
+ }
734
702
  cart_item.cart_sub_items.forEach(cart_sub_item => {
735
- let order_sub_item = DataItem.get_new(DataType.ORDER_SUB_ITEM,0,{
703
+ let order_sub_item = Data_Logic.get_new(Type.DATA_ORDER_SUB_ITEM,0,{
736
704
  order_number:order.order_number,
737
705
  parent_data_type:cart_sub_item.parent_data_type,
738
706
  parent_id:cart_sub_item.parent_id,
@@ -744,13 +712,13 @@ class Order_Logic {
744
712
  if(!Str.check_is_null(cart_sub_item[key])
745
713
  && key != Type.FIELD_ID && key != Type.DATA_TYPE
746
714
  && key != Type.TITLE_PARENT_ITEM && key != Type.TITLE_USER
747
- && key != Type.TITLE_CART_ITEMS && key != Type.TITLE_CART_SUB_ITEMS
748
- && key != Type.TITLE_ORDER_ITEMS && key != Type.TITLE_ORDER_SUB_ITEMS
749
- && key != Type.FIELD_SOURCE && key != Type.FIELD_SOURCE_ID
750
- && key != Type.FIELD_DATE_CREATE && key != Type.FIELD_DATE_SAVE){
715
+ && key != Type.TITLE_CART_ITEMS && key != Type.TITLE_CART_SUB_ITEMS
716
+ && key != Type.TITLE_ORDER_ITEMS && key != Type.TITLE_ORDER_SUB_ITEMS
717
+ && key != Type.FIELD_SOURCE && key != Type.FIELD_SOURCE_ID
718
+ && key != Type.FIELD_DATE_CREATE && key != Type.FIELD_DATE_SAVE){
751
719
  order_sub_item[key] = cart_sub_item[key];
752
- }
753
- }
720
+ }
721
+ }
754
722
  order_item.order_sub_items.push(order_sub_item);
755
723
  });
756
724
  order.order_items.push(order_item);
@@ -758,7 +726,7 @@ class Order_Logic {
758
726
  return order;
759
727
  };
760
728
  static get_new_order_payment = (order_number,payment_method_type,payment_amount) => {
761
- return DataItem.get_new(DataType.ORDER_PAYMENT,0,
729
+ return Data_Logic.get_new(Type.DATA_ORDER_PAYMENT,0,
762
730
  {
763
731
  order_number:order_number,
764
732
  payment_method_type:payment_method_type,
@@ -766,60 +734,60 @@ class Order_Logic {
766
734
  transaction_id:Title.ORDER_TRANSACTION_ID + Num.get_id(99999)
767
735
  });
768
736
  };
769
- static get_total = (order) => {
770
- let grand_total = 0;
771
- order.order_items.forEach(order_item => {
772
- order_item.sub_total = 0;
773
- if(!isNaN(order_item.cost)){
774
- order_item.sub_total = (order_item.sub_total + order_item.cost) * order_item.quanity;
775
- grand_total = grand_total + order_item.sub_total;
776
- }
777
- order_item.order_sub_items.forEach(order_sub_item => {
778
- order_sub_item.sub_total = 0;
779
- if(!isNaN(order_sub_item.cost)){
780
- order_sub_item.sub_total = (order_sub_item.sub_total + order_sub_item.cost) * order_sub_item.quanity;
781
- grand_total = grand_total + order_sub_item.sub_total;
782
- }
783
- });
784
- });
737
+ static get_total = (order) => {
738
+ let grand_total = 0;
739
+ order.order_items.forEach(order_item => {
740
+ order_item.sub_total = 0;
741
+ if(!isNaN(order_item.cost)){
742
+ order_item.sub_total = (order_item.sub_total + order_item.cost) * order_item.quanity;
743
+ grand_total = grand_total + order_item.sub_total;
744
+ }
745
+ order_item.order_sub_items.forEach(order_sub_item => {
746
+ order_sub_item.sub_total = 0;
747
+ if(!isNaN(order_sub_item.cost)){
748
+ order_sub_item.sub_total = (order_sub_item.sub_total + order_sub_item.cost) * order_sub_item.quanity;
749
+ grand_total = grand_total + order_sub_item.sub_total;
750
+ }
751
+ });
752
+ });
785
753
  order.grand_total = grand_total;
786
- return order;
787
- };
754
+ return order;
755
+ };
788
756
  }
789
757
  class Cart_Logic {
790
758
  static get_new = (parent_data_type,user_id) => {
791
- return DataItem.get_new(DataType.CART,0,{user_id:user_id,cart_number:Title.CART_NUMBER + Num.get_id(99999),parent_data_type:parent_data_type,grand_total:0,cart_items:[]});
759
+ return Data_Logic.get_new(Type.DATA_CART,0,{user_id:user_id,cart_number:Title.CART_NUMBER + Num.get_id(99999),parent_data_type:parent_data_type,grand_total:0,cart_items:[]});
792
760
  };
793
761
  static get_new_cart_item = (parent_data_type,parent_id,cart_number,quanity,cost) =>{
794
- return DataItem.get_new(DataType.CART_ITEM,0,{parent_data_type:parent_data_type,parent_id:parent_id,cart_number:cart_number,quanity:quanity?quanity:0,cost:cost?cost:0,cart_sub_items:[]});
762
+ return Data_Logic.get_new(Type.DATA_CART_ITEM,0,{parent_data_type:parent_data_type,parent_id:parent_id,cart_number:cart_number,quanity:quanity?quanity:0,cost:cost?cost:0,cart_sub_items:[]});
795
763
  };
796
764
  static get_new_cart_sub_item = (parent_data_type,parent_id,cart_number,quanity,cost) =>{
797
- return DataItem.get_new(DataType.CART_SUB_ITEM,0,{parent_data_type:parent_data_type,parent_id:parent_id,cart_number:cart_number,quanity:quanity?quanity:0,cost:cost?cost:0});
798
- };
799
- static get_total = (cart) => {
800
- let grand_total = 0;
801
- cart.cart_items.forEach(cart_item => {
802
- cart_item.sub_total = 0;
803
- if(!isNaN(cart_item.cost)){
804
- cart_item.sub_total = (cart_item.sub_total + cart_item.cost) * cart_item.quanity;
805
- grand_total = grand_total + cart_item.sub_total;
806
- }
807
- cart_item.cart_sub_items.forEach(cart_sub_item => {
808
- cart_sub_item.sub_total = 0;
809
- if(!isNaN(cart_sub_item.cost)){
810
- cart_sub_item.sub_total = (cart_sub_item.sub_total + cart_sub_item.cost) * cart_sub_item.quanity;
811
- grand_total = grand_total + cart_sub_item.sub_total;
812
- }
813
- });
814
- });
765
+ return Data_Logic.get_new(Type.DATA_CART_SUB_ITEM,0,{parent_data_type:parent_data_type,parent_id:parent_id,cart_number:cart_number,quanity:quanity?quanity:0,cost:cost?cost:0});
766
+ };
767
+ static get_total = (cart) => {
768
+ let grand_total = 0;
769
+ cart.cart_items.forEach(cart_item => {
770
+ cart_item.sub_total = 0;
771
+ if(!isNaN(cart_item.cost)){
772
+ cart_item.sub_total = (cart_item.sub_total + cart_item.cost) * cart_item.quanity;
773
+ grand_total = grand_total + cart_item.sub_total;
774
+ }
775
+ cart_item.cart_sub_items.forEach(cart_sub_item => {
776
+ cart_sub_item.sub_total = 0;
777
+ if(!isNaN(cart_sub_item.cost)){
778
+ cart_sub_item.sub_total = (cart_sub_item.sub_total + cart_sub_item.cost) * cart_sub_item.quanity;
779
+ grand_total = grand_total + cart_sub_item.sub_total;
780
+ }
781
+ });
782
+ });
815
783
  cart.grand_total = grand_total;
816
- return cart;
817
- };
784
+ return cart;
785
+ };
818
786
  }
819
787
  class Product_Logic {
820
- static get_new = (title,type,category,option) => {
788
+ static get_new = (title,type,category,option) => {
821
789
  option = option ? option : {};
822
- const item = Item_Logic.get_new(title,DataType.PRODUCT);
790
+ const item = Item_Logic.get_new(title,Type.DATA_PRODUCT);
823
791
  item.type = type;
824
792
  item.category = category = category?category:"";
825
793
  return item;
@@ -856,13 +824,11 @@ static get_new = (title,type,category,option) => {
856
824
  };
857
825
  static get_test = (title,option) =>{
858
826
  [title,option] = Field_Logic.get_option_title(title,option);
859
- option = Field_Logic.get_option(DataType.PRODUCT,option?option:{});
860
- let product = DataItem.get_new(DataType.PRODUCT,0,Field_Logic.get_test(title,option));
827
+ option = Field_Logic.get_option(Type.DATA_PRODUCT,option?option:{});
828
+ let product = Data_Logic.get_new(Type.DATA_PRODUCT,0,Field_Logic.get_test(title,option));
861
829
  if(option.get_blank ==false){
862
830
  product.cost = Field_Logic.get_test_cost();
863
831
  product.old_cost = Field_Logic.get_test_cost();
864
- product.cart_count = 0;
865
- product.order_count = 0;
866
832
  product.type = "Type "+String(Num.get_id());
867
833
  product.sub_type = "Sub Type "+String(Num.get_id());
868
834
  product.stock = String(Num.get_id(3-1));
@@ -875,15 +841,12 @@ static get_new = (title,type,category,option) => {
875
841
  product.stock = "";
876
842
  product.tag = "";
877
843
  }
878
- if(option.get_item){
879
- product.items = Sub_Item_Logic.get_test_items(product,product,option);
880
- }
881
844
  return product;
882
845
  };
883
846
  static get_test_cart = (cart_number,user_id,option) =>{
884
847
  [cart_number,option] = ield_Logic.get_option_title(cart_number,option);
885
- option = Field_Logic.get_option(DataType.CART,option?option:{});
886
- let cart = DataItem.get_new(DataType.CART,Num.get_guid(),Field_Logic.get_test(cart_number,option));
848
+ option = Field_Logic.get_option(Type.DATA_CART,option?option:{});
849
+ let cart = Data_Logic.get_new(Type.DATA_CART,Num.get_guid(),Field_Logic.get_test(cart_number,option));
887
850
  cart.user_id = user_id;
888
851
  cart.cart_number = cart_number;
889
852
  if(option.get_cart_item){
@@ -899,7 +862,7 @@ static get_new = (title,type,category,option) => {
899
862
  return cart;
900
863
  };
901
864
  static get_test_items = (option) =>{
902
- option = Field_Logic.get_option(DataType.PRODUCT,option?option:{});
865
+ option = Field_Logic.get_option(Type.DATA_PRODUCT,option?option:{});
903
866
  let items = [];
904
867
  for(let a=0;a<option.product_count+1;a++){
905
868
  items.push(Product_Logic.get_test("Product "+String(parseInt(a+1)),option));
@@ -907,9 +870,9 @@ static get_new = (title,type,category,option) => {
907
870
  return items;
908
871
  }
909
872
  static get_test_items_by_category = (option) =>{
910
- option = Field_Logic.get_option(DataType.PRODUCT,option?option:{});
873
+ option = Field_Logic.get_option(Type.DATA_PRODUCT,option?option:{});
911
874
  let products = [];
912
- let categorys = Category_Logic.get_type_categorys(DataType.PRODUCT,option.category_count);
875
+ let categorys = Category_Logic.get_type_categorys(Type.DATA_PRODUCT,option.category_count);
913
876
  let item_count = 0;
914
877
  for(let a=0;a<categorys.length;a++){
915
878
  for(let b=0;b<option.product_count;b++){
@@ -948,21 +911,18 @@ class Service_Logic {
948
911
  };
949
912
  static get_test = (title,option) =>{
950
913
  [title,option] = Field_Logic.get_option_title(title,option);
951
- option = Field_Logic.get_option(DataType.SERVICE,option?option:{});
952
- let service = DataItem.get_new(DataType.SERVICE,0,Field_Logic.get_test(title,option));
914
+ option = Field_Logic.get_option(Type.DATA_SERVICE,option?option:{});
915
+ let service = Data_Logic.get_new(Type.DATA_SERVICE,0,Field_Logic.get_test(title,option));
953
916
  service.cost = Field_Logic.get_test_cost();
954
917
  service.old_cost = Field_Logic.get_test_cost();
955
918
  service.type = "Type "+String(Num.get_id());
956
919
  service.sub_type = "Sub Type "+String(Num.get_id());
957
920
  service.stock = String(Num.get_id(3-1));
958
921
  service.tag = "Tag "+ Num.get_id() + ", Tag "+Num.get_id() + ", Tag "+ Num.get_id();
959
- if(option.get_item){
960
- service.items = Sub_Item_Logic.get_test_items(service,service,option);
961
- }
962
922
  return service;
963
923
  };
964
924
  static get_test_items = (option) =>{
965
- option = Field_Logic.get_option(DataType.SERVICE,option?option:{});
925
+ option = Field_Logic.get_option(Type.DATA_SERVICE,option?option:{});
966
926
  let items = [];
967
927
  for(let a=0;a<parseInt(option.service_count)+1;a++){
968
928
  items.push(Service_Logic.get_test("Service "+String(parseInt(a+1)),option));
@@ -970,9 +930,9 @@ class Service_Logic {
970
930
  return items;
971
931
  }
972
932
  static get_test_items_by_category = (option) =>{
973
- option = Field_Logic.get_option(DataType.SERVICE,option?option:{});
933
+ option = Field_Logic.get_option(Type.DATA_SERVICE,option?option:{});
974
934
  let services = [];
975
- let categorys = Category_Logic.get_type_categorys(DataType.SERVICE,option.category_count);
935
+ let categorys = Category_Logic.get_type_categorys(Type.DATA_SERVICE,option.category_count);
976
936
  let item_count = 0;
977
937
  for(let a=0;a<categorys.length;a++){
978
938
  for(let b=0;b<parseInt(option.service_count);b++){
@@ -988,18 +948,12 @@ class Service_Logic {
988
948
  class Content_Logic {
989
949
  static get_test = (title,option) =>{
990
950
  [title,option] = Field_Logic.get_option_title(title,option);
991
- option = Field_Logic.get_option(DataType.CONTENT,option?option:{});
992
- let content = DataItem.get_new(DataType.CONTENT,0,Field_Logic.get_test(title,option));
993
- if(option.get_item){
994
- content.items = Sub_Item_Logic.get_test_sections(content,content,option);
995
- if(option.get_item_bind){
996
- content = Sub_Item_Logic.bind_parent_child_items(content,content.items);
997
- }
998
- }
951
+ option = Field_Logic.get_option(Type.DATA_CONTENT,option?option:{});
952
+ let content = Data_Logic.get_new(Type.DATA_CONTENT,0,Field_Logic.get_test(title,option));
999
953
  return content;
1000
954
  };
1001
955
  static get_test_items = (option) =>{
1002
- option = Field_Logic.get_option(DataType.CONTENT,option?option:{});
956
+ option = Field_Logic.get_option(Type.DATA_CONTENT,option?option:{});
1003
957
  let items = [];
1004
958
  for(let a=0;a<parseInt(option.content_count)+1;a++){
1005
959
  items.push(Content_Logic.get_test("Content " +String(parseInt(a+1)),option));
@@ -1007,9 +961,9 @@ class Content_Logic {
1007
961
  return items;
1008
962
  }
1009
963
  static get_test_items_by_category = (option) =>{
1010
- option = Field_Logic.get_option(DataType.CONTENT,option?option:{});
964
+ option = Field_Logic.get_option(Type.DATA_CONTENT,option?option:{});
1011
965
  let contents = [];
1012
- let categorys = Category_Logic.get_type_categorys(DataType.CONTENT,option.category_count);
966
+ let categorys = Category_Logic.get_type_categorys(Type.DATA_CONTENT,option.category_count);
1013
967
  let item_count = 0;
1014
968
  for(let a=0;a<categorys.length;a++){
1015
969
  for(let b=0;b<parseInt(option.content_count);b++){
@@ -1025,16 +979,31 @@ class Content_Logic {
1025
979
  class Template_Logic {
1026
980
  static get_test = (title,option) =>{
1027
981
  [title,option] = Field_Logic.get_option_title(title,option);
1028
- option = Field_Logic.get_option(DataType.TEMPLATE,option?option:{});
1029
- let template = DataItem.get_new(DataType.TEMPLATE,0,Field_Logic.get_test(title,option));
982
+ option = Field_Logic.get_option(Type.DATA_TEMPLATE,option?option:{});
983
+ let template = Data_Logic.get_new(Type.DATA_TEMPLATE,0,Field_Logic.get_test(title,option));
1030
984
  return template;
1031
985
  };
1032
986
  }
987
+ class Blank_Logic {
988
+ static get_test = (title,option) =>{
989
+ [title,option] = Field_Logic.get_option_title(title,option);
990
+ option = Field_Logic.get_option(Type.DATA_BLANK,option?option:{});
991
+ let blog_post = Data_Logic.get_new(Type.DATA_BLANK,0,Field_Logic.get_test(title,option));
992
+ if(!option.get_blank){
993
+ blog_post.field_1="Field 1 "+ Num.get_id();
994
+ blog_post.field_2="Field 2 "+ Num.get_id();
995
+ }else{
996
+ blog_post.field_1="";
997
+ blog_post.field_2 = "";
998
+ }
999
+ return blog_post;
1000
+ };
1001
+ };
1033
1002
  class Blog_Post_Logic {
1034
1003
  static get_test = (title,option) =>{
1035
1004
  [title,option] = Field_Logic.get_option_title(title,option);
1036
- option = Field_Logic.get_option(DataType.BLOG_POST,option?option:{});
1037
- let blog_post = DataItem.get_new(DataType.BLOG_POST,0,Field_Logic.get_test(title,option));
1005
+ option = Field_Logic.get_option(Type.DATA_BLOG_POST,option?option:{});
1006
+ let blog_post = Data_Logic.get_new(Type.DATA_BLOG_POST,0,Field_Logic.get_test(title,option));
1038
1007
  if(!option.get_blank){
1039
1008
  blog_post.author="First Name "+ Num.get_id();
1040
1009
  blog_post.tag = "Tag "+ Num.get_id() + ", Tag "+Num.get_id() + ", Tag "+ Num.get_id(), " Tag "+ Num.get_id() + ", Tag "+Num.get_id() + ", Tag "+ Num.get_id();
@@ -1042,13 +1011,10 @@ class Blog_Post_Logic {
1042
1011
  blog_post.author="";
1043
1012
  blog_post.tag = "";
1044
1013
  }
1045
- if(option.get_item){
1046
- blog_post.items = Sub_Item_Logic.get_test_items(blog_post,blog_post,option);
1047
- }
1048
1014
  return blog_post;
1049
1015
  };
1050
1016
  static get_test_items = (option) =>{
1051
- option = Field_Logic.get_option(DataType.BLOG_POST,option?option:{});
1017
+ option = Field_Logic.get_option(Type.DATA_BLOG_POST,option?option:{});
1052
1018
  let items = [];
1053
1019
  for(let a=0;a<parseInt(option.blog_post_count)+1;a++){
1054
1020
  items.push(Blog_Post_Logic.get_test("Blog Post " +String(parseInt(a+1)),option));
@@ -1056,9 +1022,9 @@ class Blog_Post_Logic {
1056
1022
  return items;
1057
1023
  }
1058
1024
  static get_test_items_by_category = (option) =>{
1059
- option = Field_Logic.get_option(DataType.BLOG_POST,option?option:{});
1025
+ option = Field_Logic.get_option(Type.DATA_BLOG_POST,option?option:{});
1060
1026
  let blog_posts = [];
1061
- let categorys = Category_Logic.get_type_categorys(DataType.BLOG_POST,option.category_count);
1027
+ let categorys = Category_Logic.get_type_categorys(Type.DATA_BLOG_POST,option.category_count);
1062
1028
  let item_count = 0;
1063
1029
  for(let a=0;a<categorys.length;a++){
1064
1030
  for(let b=0;b<parseInt(option.blog_post_count);b++){
@@ -1074,8 +1040,8 @@ class Blog_Post_Logic {
1074
1040
  class Gallery_Logic {
1075
1041
  static get_test = (title,option) =>{
1076
1042
  [title,option] = Field_Logic.get_option_title(title,option);
1077
- option = Field_Logic.get_option(DataType.GALLERY,option?option:{});
1078
- let gallery = DataItem.get_new(DataType.GALLERY,0,Field_Logic.get_test(title,option));
1043
+ option = Field_Logic.get_option(Type.DATA_GALLERY,option?option:{});
1044
+ let gallery = Data_Logic.get_new(Type.DATA_GALLERY,0,Field_Logic.get_test(title,option));
1079
1045
  if(!option.get_blank){
1080
1046
  gallery.date = String(String(Num.get_id(2030)) + "-" + String(Num.get_id(13)) + "-" + String(Num.get_id(30))).trim();
1081
1047
  gallery.time = String(Num.get_id(24)) + ":" + String(Num.get_id(59));
@@ -1083,9 +1049,6 @@ class Gallery_Logic {
1083
1049
  }else{
1084
1050
  gallery.website = "";
1085
1051
  }
1086
- if(option.get_item){
1087
- gallery.items = Sub_Item_Logic.get_test_items(gallery,gallery,option);
1088
- }
1089
1052
  return gallery;
1090
1053
  };
1091
1054
  };
@@ -1119,8 +1082,8 @@ class Event_Logic {
1119
1082
  };
1120
1083
  static get_test = (title,option) =>{
1121
1084
  [title,option] = Field_Logic.get_option_title(title,option);
1122
- option = Field_Logic.get_option(DataType.EVENT,option?option:{});
1123
- let event = DataItem.get_new(DataType.EVENT,0,Field_Logic.get_test(title,option));
1085
+ option = Field_Logic.get_option(Type.DATA_EVENT,option?option:{});
1086
+ let event = Data_Logic.get_new(Type.DATA_EVENT,0,Field_Logic.get_test(title,option));
1124
1087
  if(!option.get_blank){
1125
1088
  event.cost = Field_Logic.get_test_cost();
1126
1089
  event.old_cost = Field_Logic.get_test_cost();
@@ -1144,13 +1107,10 @@ class Event_Logic {
1144
1107
  event.category ="";
1145
1108
  event.tag = "";
1146
1109
  }
1147
- if(option.get_item){
1148
- event.items = Sub_Item_Logic.get_test_items(event,event,option);
1149
- }
1150
1110
  return event;
1151
1111
  };
1152
1112
  static get_test_items = (option) =>{
1153
- option = Field_Logic.get_option(DataType.EVENT,option?option:{});
1113
+ option = Field_Logic.get_option(Type.DATA_EVENT,option?option:{});
1154
1114
  let items = [];
1155
1115
  for(let a=0;a<parseInt(option.event_count)+1;a++){
1156
1116
  items.push(Event_Logic.get_test("Event "+String(parseInt(a+1)),option));
@@ -1158,9 +1118,9 @@ class Event_Logic {
1158
1118
  return items;
1159
1119
  }
1160
1120
  static get_test_items_by_category = (option) =>{
1161
- option = Field_Logic.get_option(DataType.EVENT,option?option:{});
1121
+ option = Field_Logic.get_option(Type.DATA_EVENT,option?option:{});
1162
1122
  let events = [];
1163
- let categorys = Category_Logic.get_type_categorys(DataType.EVENT,option.category_count);
1123
+ let categorys = Category_Logic.get_type_categorys(Type.DATA_EVENT,option.category_count);
1164
1124
  let item_count = 0;
1165
1125
  for(let a=0;a<categorys.length;a++){
1166
1126
  for(let b=0;b<parseInt(option.event_count);b++){
@@ -1198,7 +1158,7 @@ class Field_Logic {
1198
1158
  full_prop_str = String(prop + " "+full_prop_str);
1199
1159
  }
1200
1160
  for(let a = 1; a < 75; a++){
1201
- const exists = Str.check_if_str_exist(full_prop_str,"items_value_"+a);
1161
+ const exists = Str.check_if_str_exist(full_prop_str,"items_value_"+a);
1202
1162
  if(exists){
1203
1163
  if(a>max_value_id){
1204
1164
  max_value_id = a;
@@ -1275,7 +1235,7 @@ class Field_Logic {
1275
1235
  return String(Num.get_id(999)) + "." + String(Num.get_id(99));
1276
1236
  }
1277
1237
  static get_test_note = () => {
1278
- return "Note "+String(Num.get_id()) + " Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.";
1238
+ return "Note "+String(Num.get_id()) + " Lorem Ipsum is simply dummy text of the printing and typesetting industry.";
1279
1239
  }
1280
1240
  static get_test = (title,option) =>{
1281
1241
  option = !Obj.check_is_empty(option) ? option : {};
@@ -1358,50 +1318,47 @@ class Field_Logic {
1358
1318
  return item;
1359
1319
  };
1360
1320
  static get_option(data_type,option){
1361
- data_type = data_type ? data_type : DataType.BLANK;
1362
- option = !Obj.check_is_empty(option) ? option : {get_value:false,get_item:false,get_image:false,item_count:9,value_count:9};
1321
+ data_type = data_type ? data_type : Type.DATA_BLANK;
1322
+ option = !Obj.check_is_empty(option) ? option : {get_value:false,item_count:9,value_count:9};
1363
1323
  option.generate_id = option.generate_id ? option.generate_id : false;
1364
- option.get_image = option.get_image ? true : false;
1365
1324
  option.get_value = option.get_value ? true : false;
1366
- option.get_item = option.get_item ? true : false;
1367
1325
  option.get_blank = option.get_blank ? true : false;
1368
- option.get_item_bind = option.get_item_bind ? true : true;
1369
1326
  option.value_count = option.value_count ? option.value_count : 9;
1370
1327
  option.section_count = option.section_count ? option.section_count : 9;
1371
1328
  option.item_count = option.item_count ? option.item_count : 9;
1372
1329
  option.category_count = option.category_count ? option.category_count : 9;
1373
1330
  option.category_title = option.category_title ? option.category_title : "";
1374
1331
  option.fields = option.fields ? option.fields : [];
1375
- if(option.data_type==DataType.PAGE){
1332
+ if(option.data_type==Type.DATA_PAGE){
1376
1333
  option.page_count = option.page_count ? option.page_count : 9;
1377
1334
  option.section_count = option.section_count ? option.section_count : 9;
1378
1335
  option.get_section = option.get_section ? true : false;
1379
1336
  }
1380
- if(data_type==DataType.PRODUCT){
1337
+ if(data_type==Type.DATA_PRODUCT){
1381
1338
  option.product_count = option.product_count ? option.product_count : 9;
1382
1339
  }
1383
- if(data_type==DataType.SERVICE){
1340
+ if(data_type==Type.DATA_SERVICE){
1384
1341
  option.service_count = option.service_count ? option.service_count : 9;
1385
1342
  }
1386
- if(data_type==DataType.BLOG_POST){
1343
+ if(data_type==Type.DATA_BLOG_POST){
1387
1344
  option.blog_post_count = option.blog_post_count ? option.blog_post_count : 9;
1388
1345
  }
1389
- if(data_type==DataType.EVENT){
1346
+ if(data_type==Type.DATA_EVENT){
1390
1347
  option.event_count = option.event_count ? option.event_count : 9;
1391
1348
  }
1392
- if(data_type==DataType.FAQ){
1349
+ if(data_type==Type.DATA_FAQ){
1393
1350
  option.question_count = option.question_count ? option.question_count : 9;
1394
1351
  }
1395
- if(data_type==DataType.CONTENT){
1352
+ if(data_type==Type.DATA_CONTENT){
1396
1353
  option.content_count = option.content_count ? option.content_count : 9;
1397
1354
  }
1398
- if(data_type==DataType.SUB_ITEM){
1355
+ if(data_type==Type.DATA_SUB_ITEM){
1399
1356
  option.item_count = option.item_count ? option.item_count : 9;
1400
1357
  }
1401
- if(data_type==DataType.USER){
1358
+ if(data_type==Type.DATA_USER){
1402
1359
  option.user_count = option.user_count ? option.user_count : 9;
1403
1360
  }
1404
- if(data_type==DataType.CART){
1361
+ if(data_type==Type.DATA_CART){
1405
1362
  option.category_title = option.category_title ? option.category_title : "";
1406
1363
  option.value_count = option.value_count ? option.value_count : 9;
1407
1364
  option.get_cart_item = option.get_cart_item ? option.get_cart_item : false;
@@ -1409,13 +1366,13 @@ class Field_Logic {
1409
1366
  option.get_cart_sub_item = option.get_cart_sub_item ? option.get_cart_sub_item : false;
1410
1367
  option.cart_sub_item_count = option.cart_sub_item_count ? option.cart_sub_item_count : 3;
1411
1368
  }
1412
- if(data_type==DataType.CART_ITEM){
1369
+ if(data_type==Type.DATA_CART_ITEM){
1413
1370
  option.category_title = option.category_title ? option.category_title : "";
1414
1371
  option.value_count = option.value_count ? option.value_count : 9;
1415
1372
  option.get_cart_sub_item = option.get_cart_sub_item ? option.get_cart_sub_item : false;
1416
1373
  option.cart_sub_item_count = option.cart_sub_item_count ? option.cart_sub_item_count : 1;
1417
1374
  }
1418
- if(data_type==DataType.ORDER){
1375
+ if(data_type==Type.DATA_ORDER){
1419
1376
  option.category_title = option.category_title ? option.category_title : "";
1420
1377
  option.value_count = option.value_count ? option.value_count : 9;
1421
1378
  option.get_order_item = option.get_order_item ? option.get_order_item : false;
@@ -1423,7 +1380,7 @@ class Field_Logic {
1423
1380
  option.get_order_sub_item = option.get_order_sub_item ? option.get_order_sub_item : false;
1424
1381
  option.order_sub_item_count = option.order_sub_item_count ? option.order_sub_item_count : 3;
1425
1382
  }
1426
- if(data_type==DataType.ORDER_ITEM){
1383
+ if(data_type==Type.DATA_ORDER_ITEM){
1427
1384
  option.category_title = option.category_title ? option.category_title : "";
1428
1385
  option.value_count = option.value_count ? option.value_count : 9;
1429
1386
  option.get_order_sub_item = option.get_order_sub_item ? option.get_order_sub_item : false;
@@ -1499,44 +1456,9 @@ class Field_Logic {
1499
1456
  return option;
1500
1457
  }
1501
1458
  }
1502
- class DataType {
1503
- static APP='app_biz';
1504
- static BLANK='blank_biz';
1505
- static BLOG_POST='blog_post_biz';
1506
- static CART_ITEM="cart_item_biz";
1507
- static CART="cart_biz";
1508
- static CART_ITEM="cart_item_biz";
1509
- static CART_SUB_ITEM="cart_sub_item_biz";
1510
- static CATEGORY='category_biz';
1511
- static CUSTOM_FIELD='custom_field_biz';
1512
- static CONTENT='content_biz';
1513
- static EVENT='event_biz';
1514
- static GROUP='group_biz';
1515
- static FAQ='faq_biz';
1516
- static FAVORITE='favorite_biz';
1517
- static FILE='file_biz';
1518
- static GALLERY='gallery_biz';
1519
- static IMAGE='image_biz';
1520
- static ITEM='item_biz';
1521
- static LINK='link_biz';
1522
- static ORDER="order_biz";
1523
- static ORDER_ITEM="order_item_biz";
1524
- static ORDER_SUB_ITEM="order_sub_item_biz";
1525
- static ORDER_PAYMENT="order_payment_biz";
1526
- static PRODUCT='product_biz';
1527
- static PAGE='page_biz';
1528
- static REVIEW='review_biz';
1529
- static SERVICE='service_biz';
1530
- static SECURITY='security_biz';
1531
- static STAT='stat_biz';
1532
- static TEMPLATE='template_biz';
1533
- static TYPE='type_biz';
1534
- static USER='user_biz';
1535
- static VIDEO='video_biz';
1536
- }
1537
1459
  class Favorite_Logic {
1538
1460
  static get_new = (parent_data_type,parent_id,user_id) =>{
1539
- return DataItem.get_new(DataType.FAVORITE,0,{
1461
+ return Data_Logic.get_new(Type.DATA_FAVORITE,0,{
1540
1462
  parent_data_type:parent_data_type,
1541
1463
  parent_id:parent_id,
1542
1464
  user_id:user_id
@@ -1560,7 +1482,7 @@ class Favorite_Logic {
1560
1482
  }
1561
1483
  class Review_Logic {
1562
1484
  static get_new = (parent_data_type,parent_id,user_id,title,comment,rating) =>{
1563
- return DataItem.get_new(DataType.REVIEW,0,{
1485
+ return Data_Logic.get_new(Type.DATA_REVIEW,0,{
1564
1486
  parent_data_type:parent_data_type,
1565
1487
  parent_id:parent_id,
1566
1488
  user_id:user_id,
@@ -1584,8 +1506,8 @@ class Review_Logic {
1584
1506
  ] };
1585
1507
  }
1586
1508
  static get_test = (item_data_type,item_id,user_id,option) =>{
1587
- option = Field_Logic.get_option(DataType.REVIEW,option?option:{});
1588
- let review = DataItem.get_new(DataType.REVIEW,0);
1509
+ option = Field_Logic.get_option(Type.DATA_REVIEW,option?option:{});
1510
+ let review = Data_Logic.get_new(Type.DATA_REVIEW,0);
1589
1511
  if(!option.get_blank){
1590
1512
  review.title = 'Title ' + Num.get_id();
1591
1513
  review.item_data_type = item_data_type;
@@ -1615,19 +1537,19 @@ class Review_Logic {
1615
1537
  class Admin_Logic {
1616
1538
  static get_new = (title,option) =>{
1617
1539
  [title,option] = Field_Logic.get_option_title(title,option);
1618
- return DataItem.get_new_full_item(
1619
- DataItem.get_new(DataType.ADMIN,0),
1620
- DataItem.get_new(DataType.ADMIN,0),
1621
- DataItem.get_new(DataType.ADMIN,0),{
1540
+ return Data_Logic.get_new_full_item(
1541
+ Data_Logic.get_new(Type.DATA_ADMIN,0),
1542
+ Data_Logic.get_new(Type.DATA_ADMIN,0),
1543
+ Data_Logic.get_new(Type.DATA_ADMIN,0),{
1622
1544
  title:title,
1623
1545
  email:"",
1624
1546
  });
1625
1547
  };
1626
1548
  static get_test = (title,option) =>{
1627
1549
  [title,option] = Field_Logic.get_option_title(title,option);
1628
- option = Field_Logic.get_option(DataType.ADMIN,option?option:{});
1629
- let item = DataItem.get_new(DataType.ADMIN,0);
1630
- let admin = DataItem.get_new(DataType.ADMIN,0,Field_Logic.get_test(title,option));
1550
+ option = Field_Logic.get_option(Type.DATA_ADMIN,option?option:{});
1551
+ let item = Data_Logic.get_new(Type.DATA_ADMIN,0);
1552
+ let admin = Data_Logic.get_new(Type.DATA_ADMIN,0,Field_Logic.get_test(title,option));
1631
1553
  if(!option.get_blank){
1632
1554
  admin.email="ceo@admin"+Num.get_id()+".com";
1633
1555
  admin.password="1234567";
@@ -1646,33 +1568,22 @@ class Admin_Logic {
1646
1568
  return admin.address_1 + " "+ admin.address_2 + " " + admin.city + " " + admin.state + " " + admin.zip;
1647
1569
  }
1648
1570
  }
1649
- class DataItem {
1650
- static get_new = (data_type,id,option) => {
1651
- return get_new_item_main(data_type,id,option?option:{});
1652
- };
1653
- static get_new_full_item = (item,parent_item,top_item,option) => {
1654
- return get_new_full_item_main(item,parent_item,top_item,option?option:{});
1655
- };
1656
- }
1657
1571
  class Category_Logic {
1658
1572
  static get_new = (title,type,category,option) => {
1659
1573
  option = option ? option : {};
1660
- const item = Item_Logic.get_new(title,DataType.CATEGORY);
1574
+ const item = Item_Logic.get_new(title,Type.DATA_CATEGORY);
1661
1575
  item.type = type;
1662
1576
  item.category = category = category?category:"";
1663
1577
  return item;
1664
1578
  };
1665
1579
  static get_test = (title,option) =>{
1666
1580
  title = (title) ? title : "Category 1";
1667
- option = Field_Logic.get_option(DataType.CATEGORY,option?option:{});
1668
- let category = DataItem.get_new(DataType.CATEGORY,0,Field_Logic.get_test(title,option));
1669
- if(option.get_item){
1670
- category.items = Sub_Item_Logic.get_test_items(category,category,option);
1671
- }
1581
+ option = Field_Logic.get_option(Type.DATA_CATEGORY,option?option:{});
1582
+ let category = Data_Logic.get_new(Type.DATA_CATEGORY,0,Field_Logic.get_test(title,option));
1672
1583
  return category;
1673
1584
  };
1674
1585
  static get_test_items = (option) =>{
1675
- option = Field_Logic.get_option(DataType.CATEGORY,option);
1586
+ option = Field_Logic.get_option(Type.DATA_CATEGORY,option);
1676
1587
  let items = [];
1677
1588
  for(let a=0;a<option.category_count;a++){
1678
1589
  items.push(Category_Logic.get_test("Category " +String(parseInt(a+1)),option));
@@ -1680,10 +1591,10 @@ class Category_Logic {
1680
1591
  return items;
1681
1592
  }
1682
1593
  static get_test_items_by_type = (type,option) =>{
1683
- option = Field_Logic.get_option(DataType.CATEGORY,option);
1594
+ option = Field_Logic.get_option(Type.DATA_CATEGORY,option);
1684
1595
  let categorys = [];
1685
1596
  for(let a=0;a<option.category_count;a++){
1686
- let category = DataItem.get_new(DataType.CATEGORY,0,Field_Logic.get_test("Category " +String(parseInt(a+1)),option));
1597
+ let category = Data_Logic.get_new(Type.DATA_CATEGORY,0,Field_Logic.get_test("Category " +String(parseInt(a+1)),option));
1687
1598
  category.type = type;
1688
1599
  categorys.push(category);
1689
1600
  }
@@ -1775,11 +1686,11 @@ class User_Logic {
1775
1686
 
1776
1687
  }
1777
1688
  static get_guest(){
1778
- return DataItem.get_new(DataType.USER,0,{is_guest:true,title_url:'guest',first_name:'Guest',last_name:'User',email:'guest@email.com',title:"Guest",country:"United States"});
1689
+ return Data_Logic.get_new(Type.DATA_USER,0,{is_guest:true,title_url:'guest',first_name:'Guest',last_name:'User',email:'guest@email.com',title:"Guest",country:"United States"});
1779
1690
  }
1780
1691
  static get_request_user(req){
1781
1692
  if(!req || !req.session.user){
1782
- let user=DataItem.get_new(DataType.USER,Num.get_id(9999999),{is_guest:true});
1693
+ let user=Data_Logic.get_new(Type.DATA_USER,Num.get_id(9999999),{is_guest:true});
1783
1694
  req.session.user=user;
1784
1695
  }
1785
1696
  return req.session.user;
@@ -1793,8 +1704,8 @@ class User_Logic {
1793
1704
  }
1794
1705
  static get_test = (title,option) =>{
1795
1706
  [title,option] = Field_Logic.get_option_title(title,option);
1796
- option = Field_Logic.get_option(DataType.USER,option?option:{});
1797
- let user = DataItem.get_new(DataType.USER,0,
1707
+ option = Field_Logic.get_option(Type.DATA_USER,option?option:{});
1708
+ let user = Data_Logic.get_new(Type.DATA_USER,0,
1798
1709
  Field_Logic.get_test(title,option));
1799
1710
  if(option.get_blank){
1800
1711
  user.first_name="";
@@ -1816,7 +1727,7 @@ class User_Logic {
1816
1727
  return user;
1817
1728
  };
1818
1729
  static get_test_items = (option) =>{
1819
- option = Field_Logic.get_option(DataType.USER,option?option:{});
1730
+ option = Field_Logic.get_option(Type.DATA_USER,option?option:{});
1820
1731
  let items = [];
1821
1732
  for(let a=0;a<option.user_count+1;a++){
1822
1733
  items.push(User_Logic.get_test("User " +String(parseInt(a+1)),option));
@@ -1824,51 +1735,125 @@ class User_Logic {
1824
1735
  return items;
1825
1736
  }
1826
1737
  }
1827
- class Sub_Item_Logic {
1828
- static get_test(title,parent_item,top_item,option){
1829
- option = Field_Logic.get_option(DataType.ITEM,option?option:{});
1830
- let item_title =title;
1831
- let item = DataItem.get_new(
1832
- DataType.ITEM,0, {
1833
- top_id:top_item.id?top_item.id:0,
1834
- top_data_type:top_item.data_type?top_item.data_type:DataType.BLANK,
1835
- parent_id:parent_item.id?parent_item.id:0,
1836
- parent_data_type:parent_item.data_type?parent_item.data_type:DataType.BLANK,
1837
- title:item_title,
1838
- title_url:Str.get_title_url(item_title),
1839
- description:"Description "+String(Num.get_id()),
1840
- note:Field_Logic.get_test_note()
1738
+ class Data_Logic {
1739
+ static get_new = (data_type,id,data) => {
1740
+ return get_new_item_main(data_type,id,data?data:{});
1741
+ };
1742
+ static get_biz = (data_type,id,option) => {
1743
+ option = option ? option : {};
1744
+ option.data = option.data ? option.data : {};
1745
+ if(option.test){
1746
+ switch(data_type)
1747
+ {
1748
+ case Type.DATA_CATEGORY:
1749
+ option.data = Obj.merge(Category_Logic.get_test(),option.data);
1750
+ break;
1751
+ case Type.DATA_BLOG_POST:
1752
+ option.data = Obj.merge(Blog_Post_Logic.get_test(),option.data);
1753
+ break;
1754
+ case Type.DATA_SERVICE:
1755
+ option.data = Obj.merge(Service_Logic.get_test(),option.data);
1756
+ break;
1757
+ case Type.DATA_PRODUCT:
1758
+ option.data = Obj.merge(Product_Logic.get_test(),option.data);
1759
+ break;
1760
+ case Type.DATA_BLANK:
1761
+ option.data = Obj.merge(Blank_Logic.get_test(),option.data);
1762
+ break;
1763
+ case Type.DATA_USER:
1764
+ option.data = Obj.merge(User_Logic.get_test(),option.data);
1765
+ break;
1766
+ default:
1767
+ option.data = Obj.merge(Blank_Logic.get_test(),option.data);
1768
+ option.data.data_type = Type.DATA_GROUP;
1769
+ break;
1841
1770
  }
1842
- );
1843
- if(option.get_value){
1844
- item = Field_Logic.get_values(item,option);
1845
1771
  }
1846
- return item;
1847
- }
1848
- static get_test_items(parent_item,top_item,option){
1849
- option = Field_Logic.get_option(DataType.SUB_ITEM,option?option:{});
1850
- let items = [];
1851
- for(let a=0;a<option.item_count;a++){
1852
- let item_title ="Item " + String(parseInt(a+1));
1853
- items.push(Sub_Item_Logic.get_test(item_title,parent_item,top_item,option));
1772
+ if(option.parent){
1773
+ option.data[Type.FIELD_PARENT_DATA_TYPE] = option.parent[Type.FIELD_DATA_TYPE] ? option.parent[Type.FIELD_DATA_TYPE] : Type.DATA_BLANK;
1774
+ option.data[Type.FIELD_PARENT_ID] = option.parent[Type.FIELD_ID] ? option.parent[Type.FIELD_ID] : 0;
1854
1775
  }
1855
- return items;
1856
- }
1857
- static get_test_sections(parent_item,top_item,option){
1858
- let items = [];
1859
- for(let a=0;a<option.section_count;a++){
1860
- let item_title ="Section " + String(parseInt(a+1));
1861
- let item = Sub_Item_Logic.get_test(item_title,parent_item,top_item,option);
1862
- items.push(item);
1776
+ if(option.generate_title){
1777
+ option.title = Type.get_title(data_type) + " " +Num.get_id();
1863
1778
  }
1864
- return items;
1865
- }
1866
- static bind_parent_child_items(item,items){
1867
- for(let a=0;a<items.length;a++){
1868
- item[Str.get_title_url(items[a].title)] = items[a];
1779
+ if(option.title){
1780
+ option.data[Type.FIELD_TITLE] = option.title;
1781
+ option.data[Type.FIELD_TITLE_URL] = Str.get_title_url(option.title);
1782
+ }else{
1783
+ option.data[Type.FIELD_TITLE] = Type.get_title(data_type);
1784
+ option.data[Type.FIELD_TITLE_URL] = Str.get_title_url(Type.get_title(data_type));
1869
1785
  }
1870
- return item;
1786
+ let data = Data_Logic.get_new(data_type,id,option.data?option.data:{});
1787
+ return data;
1788
+ };
1789
+ static get_search = (data_type,filter,sort_by,page_current,page_size) => {
1790
+ return {data_type:data_type,filter:filter,sort_by:sort_by,page_current:page_current,page_size:page_size};
1791
+ }
1792
+ static get_search_group = (option) => {
1793
+ option = option ? option : {};
1794
+ let type = option.type ? option.type : Type.TITLE_ITEMS;
1795
+ let field = option.field ? option.field : {};
1796
+ let title = option.title ? option.title : {};
1797
+ let image = option.image ? option.image : {count:0,sort_by:Type.TITLE_SORT_BY_ASC};
1798
+ let page_current = option.page_current ? option.page_current : 0;
1799
+ let page_size = option.page_size ? option.page_size : 0;
1800
+ return {type:type,field:field,title:title,image:image,page_current:page_current,page_size:page_size};
1871
1801
  }
1802
+ static get_search_foreign = (type,foreign_data_type,foreign_field,parent_field,option) => {
1803
+ option = option ? option : {};
1804
+ type = type ? type : Type.TITLE_ITEMS;
1805
+ foreign_data_type = foreign_data_type ? foreign_data_type : Str.get_title_url(Type.get_title(foreign_data_type,{plural:true}));
1806
+ foreign_field = foreign_field ? foreign_field : Type.FIELD_PARENT_ID;
1807
+ parent_field = parent_field ? parent_field : parent_field;
1808
+ let field = option.field ? option.field : {};
1809
+ let title = option.title ? option.title : Str.get_title_url(Type.get_title(foreign_data_type,{plural:true}));
1810
+ let page_current = option.page_current ? option.page_current : 0;
1811
+ let page_size = option.page_size ? option.page_size : 0;
1812
+ return {type:type,foreign_data_type:foreign_data_type,foreign_field:foreign_field,parent_field:parent_field,type:type,field:field,title:title,page_current:page_current,page_size:page_size};
1813
+ }
1814
+ static get_search_join = (type,search,option) => {
1815
+ option = option ? option : {};
1816
+ type = type ? type : Type.TITLE_ITEMS;
1817
+ search = search ? search : Data_Logic.get_search(Type.DATA_BLANK,{},{},1,0);
1818
+ let field = option.field ? option.field : {};
1819
+ let title = option.title ? option.title : Str.get_title_url(Type.get_title(search.data_type,{plural:true}));
1820
+ let page_current = option.page_current ? option.page_current : 1;
1821
+ let page_size = option.page_size ? option.page_size : 0;
1822
+ return {type:type,search:search,field:field,title:title,page_current:page_current,page_size:page_size};
1823
+ }
1824
+ static get_not_found = (data_type,id,option) =>{
1825
+ option=option?option:{};
1826
+ if(!data_type){
1827
+ data_type = Type.DATA_BLANK;
1828
+ }
1829
+ if(!id){
1830
+ id = 0;
1831
+ }
1832
+ if(data_type != Type.DATA_USER){
1833
+ if(!id){
1834
+ id=0;
1835
+ }
1836
+ let item = Item_Logic.get_test("",data_type,id,{get_blank:true})
1837
+ item.id = 0;
1838
+ item.id_key = id;
1839
+ item.title = "Item Not Found";
1840
+ item.title_url = Str.get_title_url(item.title);
1841
+ item.images = [];
1842
+ item.items = [];
1843
+ return item;
1844
+ }else{
1845
+ let user = User_Logic.get_test("",{get_blank:true})
1846
+ user.id = 0;
1847
+ user.id_key = id;
1848
+ user.title = "User Not Found";
1849
+ user.first_name = "User Not Found";
1850
+ user.title_url = Str.get_title_url(user.title);
1851
+ user.images = [];
1852
+ user.items = [];
1853
+ return user;
1854
+ }
1855
+ };
1856
+
1872
1857
  }
1873
1858
  class App_Logic {
1874
1859
  static get_url = (app_id,host,url,param) => {
@@ -1881,13 +1866,13 @@ class App_Logic {
1881
1866
  for(const prop in user) {
1882
1867
  item['user_'+prop] = user[prop];
1883
1868
  }
1884
- return item;
1869
+ return item;
1885
1870
  };
1886
1871
  static bind_item_parent_users = (items)=>{
1887
1872
  for(let item of items) {
1888
1873
  item = App_Logic.bind_item_parent_user_obj(item);
1889
1874
  }
1890
- return items;
1875
+ return items;
1891
1876
  };
1892
1877
  static bind_item_parent_user_obj = (item)=>{
1893
1878
  if(!item.user){
@@ -1902,7 +1887,7 @@ class App_Logic {
1902
1887
  for(const prop in item.user) {
1903
1888
  item['user_'+prop] = item.user[prop];
1904
1889
  }
1905
- return item;
1890
+ return item;
1906
1891
  };
1907
1892
  static url_dashboard_user_home = (app_id,url,param) => {
1908
1893
  let action_url="dashboard/user_home";
@@ -1913,49 +1898,19 @@ class App_Logic {
1913
1898
  return get_cloud_url_main(app_id,url,action_url,param);
1914
1899
  };
1915
1900
  static get_new = (title,user_id,type,option) =>{
1916
- option = Field_Logic.get_option(DataType.APP,option?option:{});
1917
- let app = DataItem.get_new(DataType.APP,0);
1901
+ option = Field_Logic.get_option(Type.DATA_APP,option?option:{});
1902
+ let app = Data_Logic.get_new(Type.DATA_APP,0);
1918
1903
  app.title = title;
1919
1904
  app.user_id = user_id;
1920
1905
  app.type = type;
1921
1906
  return app;
1922
1907
  }
1923
- static get_search = (data_type,filter,sort_by,page_current,page_size) => {
1924
- return {data_type:data_type,filter:filter,sort_by:sort_by,page_current:page_current,page_size:page_size};
1925
- }
1926
- static get_not_found = (data_type,id,option) =>{
1927
- option=option?option:{};
1928
- if(data_type != DataType.USER){
1929
- if(!id){
1930
- id=0;
1931
- }
1932
- let item = Item_Logic.get_test("",data_type,id,{get_blank:true})
1933
- item.id = 0;
1934
- item.id_key = id;
1935
- item.title = "Item Not Found";
1936
- item.title_url = Str.get_title_url(item.title);
1937
- item.images = [];
1938
- item.items = [];
1939
- return item;
1940
- }else{
1941
- let user = User_Logic.get_test("",{get_blank:true})
1942
- user.id = 0;
1943
- user.id_key = id;
1944
- user.title = "User Not Found";
1945
- user.first_name = "User Not Found";
1946
- user.title_url = Str.get_title_url(user.title);
1947
- user.images = [];
1948
- user.items = [];
1949
- return user;
1950
- }
1951
-
1952
- };
1953
1908
  static get_search_query(search){
1954
1909
  let url = "";
1955
1910
  if(search.data_type){
1956
1911
  url = url + "&data_type="+search.data_type;
1957
1912
  }else{
1958
- url = url + "&data_type="+DataType.BLANK;
1913
+ url = url + "&data_type="+Type.DATA_BLANK;
1959
1914
  }
1960
1915
  if(search.sort_by_key){
1961
1916
  url = url + "&sort_by_key="+search.sort_by_key;
@@ -1996,12 +1951,12 @@ class App_Logic {
1996
1951
  filter[query['filter_key_'+a]] = query['filter_value_'+a]
1997
1952
  }
1998
1953
  }
1999
- return App_Logic.get_search(query.data_type,filter,sort_by,query.page_current,query.page_size);
1954
+ return Data_Logic.get_search(query.data_type,filter,sort_by,query.page_current,query.page_size);
2000
1955
  }
2001
1956
  static get_data_search_result = (app_id,data_type,item_count,page_count,filter,items,option) =>{
2002
1957
  return{
2003
1958
  option:option?option:{},
2004
- data_type:data_type?data_type:DataType.BLANK,
1959
+ data_type:data_type?data_type:Type.DATA_BLANK,
2005
1960
  item_count:item_count?item_count:0,
2006
1961
  page_count:page_count?page_count:1,
2007
1962
  filter:filter?filter:{},
@@ -2026,12 +1981,12 @@ class File_Logic {
2026
1981
  return host+"/"+size + "_"+file_filename+param;
2027
1982
  }
2028
1983
  static get_new_by_base64 = (item_file) =>{
2029
- let item = DataItem.get_new(DataType.FILE,0,item_file);
2030
- item.extension = !Str.check_is_null(Str.get_file_type_from_base64(item.file_data)) ? Str.get_file_type_from_base64(item.file_data).extension : 'txt';
2031
- item.file_filename = !Str.check_is_null(Str.get_file_type_from_base64(item.file_data)) ? Str.get_guid()+ "." + item.extension : 'not_found.txt';
2032
- item.buffer = !Str.check_is_null(Str.get_file_type_from_base64(item_file.file_data)) ? Buffer.from(item_file.file_data.split(';base64,').pop(), 'base64') : null;
2033
- return item;
2034
- };
1984
+ let item = Data_Logic.get_new(Type.DATA_FILE,0,item_file);
1985
+ item.extension = !Str.check_is_null(Str.get_file_type_from_base64(item.file_data)) ? Str.get_file_type_from_base64(item.file_data).extension : 'txt';
1986
+ item.file_filename = !Str.check_is_null(Str.get_file_type_from_base64(item.file_data)) ? Str.get_guid()+ "." + item.extension : 'not_found.txt';
1987
+ item.buffer = !Str.check_is_null(Str.get_file_type_from_base64(item_file.file_data)) ? Buffer.from(item_file.file_data.split(';base64,').pop(), 'base64') : null;
1988
+ return item;
1989
+ };
2035
1990
  };
2036
1991
  class Image_Logic {
2037
1992
  static url_post = (app_id,url,param) => {
@@ -2050,12 +2005,12 @@ class Image_Logic {
2050
2005
  return host+"/"+size + "_"+image_filename+param;
2051
2006
  }
2052
2007
  static get_new_by_base64 = (item_image) =>{
2053
- let item = DataItem.get_new(DataType.IMAGE,0,item_image);
2054
- item.extension = !Str.check_is_null(Str.get_file_type_from_base64(item.image_data)) ? Str.get_file_type_from_base64(item.image_data).extension : 'jpeg';
2055
- item.image_filename = !Str.check_is_null(Str.get_file_type_from_base64(item.image_data)) ? Str.get_guid()+ "." + item.extension : 'not_found.jpeg';
2056
- item.buffer = !Str.check_is_null(Str.get_file_type_from_base64(item_image.image_data)) ? Buffer.from(item_image.image_data.split(';base64,').pop(), 'base64') : null;
2057
- return item;
2058
- };
2008
+ let item = Data_Logic.get_new(Type.DATA_IMAGE,0,item_image);
2009
+ item.extension = !Str.check_is_null(Str.get_file_type_from_base64(item.image_data)) ? Str.get_file_type_from_base64(item.image_data).extension : 'jpeg';
2010
+ item.image_filename = !Str.check_is_null(Str.get_file_type_from_base64(item.image_data)) ? Str.get_guid()+ "." + item.extension : 'not_found.jpeg';
2011
+ item.buffer = !Str.check_is_null(Str.get_file_type_from_base64(item_image.image_data)) ? Buffer.from(item_image.image_data.split(';base64,').pop(), 'base64') : null;
2012
+ return item;
2013
+ };
2059
2014
  static get_process_items = (upload_dir,image_filename) =>{
2060
2015
  upload_dir = upload_dir ? upload_dir : "";
2061
2016
  image_filename = image_filename ? image_filename : "";
@@ -2112,6 +2067,7 @@ class Url {
2112
2067
  static CART_POST="item/cart_post";
2113
2068
  //cms
2114
2069
  static CMS_DEMO_POST="cms/demo_post";
2070
+ static CMS_GET="cms/get";
2115
2071
  static CMS_POST="cms/post";
2116
2072
  static CMS_ITEM_PARENT_TOP_TYPE_CATEGORY="cms/item_parent_top_type_category";
2117
2073
  static CMS_SEARCH_ITEM_TYPE_CATEGORY="cms/search_item_type_category";
@@ -2189,13 +2145,12 @@ class Url {
2189
2145
  module.exports = {
2190
2146
  App_Logic,
2191
2147
  Admin_Logic,
2148
+ Blank_Logic,
2192
2149
  Blog_Post_Logic,
2193
2150
  Cart_Logic,
2194
2151
  Category_Logic,
2195
2152
  Content_Logic,
2196
- DataItem,
2197
- DataType,
2198
- Demo_Logic,
2153
+ Data_Logic,
2199
2154
  Event_Logic,
2200
2155
  File_Logic,
2201
2156
  Field_Logic,
@@ -2209,7 +2164,6 @@ module.exports = {
2209
2164
  Product_Logic,
2210
2165
  Review_Logic,
2211
2166
  Service_Logic,
2212
- Sub_Item_Logic,
2213
2167
  Stat_Logic,
2214
2168
  Storage,
2215
2169
  Template_Logic,