biz9-logic 4.0.20 → 4.0.21

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.
package/biz9_config CHANGED
@@ -1,4 +1,4 @@
1
- VERSION='4.2.0'
1
+ VERSION='4.2.1'
2
2
  TITLE='BiZ9-Logic';
3
3
  REPO='git@github.com:biz9framework/biz9-logic.git';
4
4
  BRANCH='main';
package/index.js CHANGED
@@ -28,10 +28,9 @@ class Template{
28
28
  Field.get_test("Primary"));
29
29
  let template_sub_title_list = ["Header","Navigation","Body","Footer"];
30
30
  for(let a=0;a<template_sub_title_list.length;a++){
31
- template = Sub_Item.get_test_bind_new_child(Number.get_id(),template_sub_title_list[a],template,template,template);
31
+ template = Sub_Item.get_test_bind_new_child(Number.get_id(),template_sub_title_list[a],template,template,template);
32
32
  }
33
33
  template = Sub_Item.get_test_bind_item_sub_item(template);
34
- Log.w('template_sec',template.header.section_1.section_1);
35
34
  return template;
36
35
  };
37
36
  }
@@ -48,29 +47,50 @@ class Page{
48
47
  }
49
48
  page = Sub_Item.get_test_bind_item_sub_item(page);
50
49
 
51
- return page;
50
+ return page;
52
51
  };
53
52
  }
54
53
  class Product{
55
- static get_test = (title) =>{
54
+ static get_test = (title,option) =>{
55
+ if(!option){
56
+ option={};
57
+ }
56
58
  let product = DataItem.get_new_full_item(
57
59
  DataItem.get_new(DataType.PRODUCT,Number.get_id()),
58
60
  DataItem.get_new(DataType.PRODUCT,0),
59
61
  DataItem.get_new(DataType.PRODUCT,0),
60
62
  Field.get_test(title));
61
- product = Sub_Item.get_test_bind_new_child(Number.get_id(),title,product,product,product);
62
63
  product.cost = String(Number.get_id()) + "." + String(Number.get_id());
63
64
  product.old_cost = String(Number.get_id()) + "." + String(Number.get_id());
64
65
  product.type = "Type "+String(Number.get_id());
65
66
  product.sub_type = "Sub Type "+String(Number.get_id());
66
67
  product.stock = String(Number.get_id(3-1));
68
+ product.category = Category.get_type_category_list(DataType.PRODUCT)[Number.get_id(Category.get_type_category_list(DataType.PRODUCT).length-1)].title;
69
+ if(option.get_items){
70
+ product = Sub_Item.get_test_bind_new_child(Number.get_id(),title,product,product,product);
67
71
  for(let a=0;a<10;a++){
68
72
  product=Sub_Item.get_test_bind_new_child(Number.get_id(),"Section " + String(a),product,product,product);
69
73
  }
70
74
  product = Sub_Item.get_test_bind_item_sub_item(product);
71
- return product;
75
+ }
76
+ return product;
77
+ };
78
+ static get_test_list_by_category = (option) =>{
79
+ let product_list = [];
80
+ let category_list = Category.get_type_category_list(DataType.PRODUCT);
81
+ for(let a=0;a<category_list.length;a++){
82
+ for(let b=0;b<19;b++){
83
+ let product = Product.get_test("Product " + b);
84
+ product.category = category_list[Number.get_id(category_list.length-1)].title;
85
+ product_list.push(product);
86
+ }
87
+ }
88
+ //Log.w('category_list',category_list.length);
89
+ //Log.w('product_list',product_list.length);
90
+ return [category_list,product_list]
72
91
  };
73
92
  }
93
+
74
94
  class Service{
75
95
  static get_test = (title) =>{
76
96
  let service = DataItem.get_new_full_item(
@@ -114,24 +134,24 @@ class Event{
114
134
  return event;
115
135
  };
116
136
  }
117
- class Field{
118
- static get_test = (title) =>{
119
- let item = {
120
- date_create:new moment().toISOString(),
121
- date_save:new moment().toISOString(),
122
- title:title,
123
- setting_visible:"1",
124
- photo_data:"/images/no_img.jpg",
125
- title_url:Str.get_title_url(title),
126
- sub_note : "Sub Note "+String(Number.get_id()),
127
- note : "Note "+String(Number.get_id())
128
- }
129
- for(let b = 1;b<20;b++){
130
- item['value_'+String(b)] = 'value ' + String(b);
131
- }
132
- return item;
133
- }
134
- }
137
+ class Field{
138
+ static get_test = (title) =>{
139
+ let item = {
140
+ date_create:new moment().toISOString(),
141
+ date_save:new moment().toISOString(),
142
+ title:title,
143
+ setting_visible:"1",
144
+ photo_data:"/images/no_img.jpg",
145
+ title_url:Str.get_title_url(title),
146
+ sub_note : "Sub Note "+String(Number.get_id()),
147
+ note : "Note "+String(Number.get_id())
148
+ }
149
+ for(let b = 1;b<20;b++){
150
+ item['value_'+String(b)] = 'value ' + String(b);
151
+ }
152
+ return item;
153
+ }
154
+ }
135
155
  class FieldType {
136
156
  static APP_ID='app_id';
137
157
  static ID='id';
@@ -212,6 +232,15 @@ class DataType {
212
232
  return String(Str.get_title(data_type.replaceAll('_',' ').replaceAll('dt','').replace('biz',''))).trim();
213
233
  }
214
234
  }
235
+ static get_item_list = () =>{
236
+ return [
237
+ { title:DataType.get_title(DataType.BLOG_POST),type:DataType.BLOG_POST},
238
+ { title:DataType.get_title(DataType.SERVICE),type:DataType.SERVICE},
239
+ { title:DataType.get_title(DataType.EVENT),type:DataType.EVENT},
240
+ { title:DataType.get_title(DataType.GALLERY),type:DataType.GALLERY},
241
+ { title:DataType.get_title(DataType.PRODUCT),type:DataType.PRODUCT}
242
+ ]
243
+ };
215
244
  static ADMIN='admin_biz';
216
245
  static BLANK='blank_biz';
217
246
  static BUSINESS='business_biz';
@@ -383,7 +412,29 @@ class Obj {
383
412
  return get_cloud_filter_obj_main(data_type,filter,sort_by,page_current,page_size);
384
413
  }
385
414
  };
386
- class Cat {
415
+ class Category {
416
+ static get_test(){
417
+ let category = DataItem.get_new_full_item(
418
+ DataItem.get_new(DataType.CATEGORY,Number.get_id()),
419
+ DataItem.get_new(DataType.CATEGORY,0),
420
+ DataItem.get_new(DataType.CATEGORY,0),
421
+ Field.get_test("Category " +Number.get_id()));
422
+ category.type = Category.get_category_list()[Number.get_id(category_list.length-1)].data_type;
423
+ return category;
424
+ }
425
+ static get_type_category_list(type){
426
+ let category_list = [];
427
+ for(let a=0;a<20;a++){
428
+ let category = DataItem.get_new_full_item(
429
+ DataItem.get_new(DataType.CATEGORY,"Category "+Number.get_id()),
430
+ DataItem.get_new(DataType.CATEGORY,0),
431
+ DataItem.get_new(DataType.CATEGORY,0),
432
+ Field.get_test("Category " +Number.get_id()));
433
+ category.type = type
434
+ category_list.push(category);
435
+ }
436
+ return category_list;
437
+ };
387
438
  static get_category_drop_down_list_by_list = (cat_list) => {
388
439
  let category_list = [];
389
440
  for(let a=0;a<cat_list.length;a++){
@@ -393,13 +444,13 @@ class Cat {
393
444
  };
394
445
  static get_category_list = () => {
395
446
  return [
396
- { value: DataType.BLOG_POST, label: "Blog Posts" },
397
- { value: DataType.CONTENT, label: "Content" },
398
- { value: DataType.EVENT, label: "Events" },
399
- { value: DataType.GALLERY, label: "Galleries" },
400
- { value: DataType.SERVICE, label: "Services" },
401
- { value: DataType.PRODUCT, label: "Products" },
402
- { value: DataType.TEMPLATE, label: "Template" }
447
+ {data_type:DataType.BLOG_POST,value:DataType.BLOG_POST,label:"Blog Posts"},
448
+ {data_type:DataType.CONTENT,value:DataType.CONTENT,label:"Content"},
449
+ {data_type:DataType.EVENT,value:DataType.EVENT,label:"Events"},
450
+ {data_type:DataType.GALLERY,value:DataType.GALLERY,label:"Galleries"},
451
+ {data_type:DataType.SERVICE,value:DataType.SERVICE,label:"Services"},
452
+ {data_type:DataType.PRODUCT,value:DataType.PRODUCT,label:"Product"},
453
+ {data_type:DataType.TEMPLATE,value:DataType.TEMPLATE,label:"Template"}
403
454
  ];
404
455
  };
405
456
  static get_title_by_type = (data_type) => {
@@ -722,22 +773,22 @@ class Sub_Item{
722
773
  item[Str.get_title_url(title)] = new_sub_item;
723
774
  item.items.push(new_sub_item);
724
775
  return item;
725
- function get_bind_test_field(title){
726
- let item = {
727
- date_create:new moment().toISOString(),
728
- date_save:new moment().toISOString(),
729
- title:title,
730
- setting_visible:"1",
731
- photo_data:"/images/no_img.jpg",
732
- title_url:Str.get_title_url(title),
733
- sub_note : "Sub Note "+String(Number.get_id()),
734
- note : "Note "+String(Number.get_id())
735
- }
736
- for(let b = 1;b<20;b++){
737
- item['value_'+String(b)] = title+ ' value ' + String(b);
738
- }
739
- return item;
740
- };
776
+ function get_bind_test_field(title){
777
+ let item = {
778
+ date_create:new moment().toISOString(),
779
+ date_save:new moment().toISOString(),
780
+ title:title,
781
+ setting_visible:"1",
782
+ photo_data:"/images/no_img.jpg",
783
+ title_url:Str.get_title_url(title),
784
+ sub_note : "Sub Note "+String(Number.get_id()),
785
+ note : "Note "+String(Number.get_id())
786
+ }
787
+ for(let b = 1;b<20;b++){
788
+ item['value_'+String(b)] = title+ ' value ' + String(b);
789
+ }
790
+ return item;
791
+ };
741
792
 
742
793
  };
743
794
 
@@ -745,7 +796,7 @@ class Sub_Item{
745
796
  module.exports = {
746
797
  BiZ_Url,
747
798
  Business,
748
- Cat,
799
+ Category,
749
800
  CMS,
750
801
  DataItem,
751
802
  DataType,
package/main.js CHANGED
@@ -56,10 +56,19 @@ const get_title_url_main = (title) => {
56
56
  }
57
57
  return title.replace(/[^a-z0-9]+/ig, "_").toLowerCase();
58
58
  }
59
+ const get_title_main = (data_type) => {
60
+ if(!data_type){
61
+ return "";
62
+ }else{
63
+ return String(Str.get_title(data_type.replaceAll('_',' ').replaceAll('dt','').replace('biz',''))).trim();
64
+ }
65
+ }
66
+
59
67
  module.exports = {
60
68
  get_new_item_main,
61
69
  get_cloud_url_main,
62
70
  get_cloud_filter_obj_main,
63
71
  get_title_url_main,
64
- get_new_full_item_main
72
+ get_new_full_item_main,
73
+ get_title_main
65
74
  };
package/main_test.js ADDED
@@ -0,0 +1,112 @@
1
+ const { DataItem,DataType } = require('biz9-logic');
2
+ console.log('aaaaaa');
3
+ console.log('aaaaaa');
4
+ console.log('aaaaaa');
5
+ console.log(DataType);
6
+ console.log('bbbbbbbb');
7
+ const get_template_test = () =>{
8
+ let template = DataItem.get_new_full_item(
9
+ DataItem.get_new(DataType.TEMPLATE,Number.get_id()),
10
+ DataItem.get_new(DataType.TEMPLATE,0),
11
+ DataItem.get_new(DataType.TEMPLATE,0),
12
+ Field.get_test("Primary"));
13
+ let template_sub_title_list = ["Header","Navigation","Body","Footer"];
14
+ for(let a=0;a<template_sub_title_list.length;a++){
15
+ template = Sub_Item.get_test_bind_new_child(Number.get_id(),template_sub_title_list[a],template,template,template);
16
+ }
17
+ template = Sub_Item.get_test_bind_item_sub_item(template);
18
+ return template;
19
+ };
20
+ const get_page_test = (title) =>{
21
+ let page = DataItem.get_new_full_item(
22
+ DataItem.get_new(DataType.PAGE,Number.get_id()),
23
+ DataItem.get_new(DataType.PAGE,0),
24
+ DataItem.get_new(DataType.PAGE,0),
25
+ Field.get_test(title));
26
+ for(let a=0;a<20;a++){
27
+ page=Sub_Item.get_test_bind_new_child(Number.get_id(),"Section "+a,page,page,page);
28
+ }
29
+ page = Sub_Item.get_test_bind_item_sub_item(page);
30
+ return page;
31
+ }
32
+ const get_product_test = (title) =>{
33
+ let product = DataItem.get_new_full_item(
34
+ DataItem.get_new(DataType.PRODUCT,Number.get_id()),
35
+ DataItem.get_new(DataType.PRODUCT,0),
36
+ DataItem.get_new(DataType.PRODUCT,0),
37
+ Field.get_test(title));
38
+ product = Sub_Item.get_test_bind_new_child(Number.get_id(),title,product,product,product);
39
+ product.cost = String(Number.get_id()) + "." + String(Number.get_id());
40
+ product.old_cost = String(Number.get_id()) + "." + String(Number.get_id());
41
+ product.type = "Type "+String(Number.get_id());
42
+ product.sub_type = "Sub Type "+String(Number.get_id());
43
+ product.stock = String(Number.get_id(3-1));
44
+ for(let a=0;a<10;a++){
45
+ product=Sub_Item.get_test_bind_new_child(Number.get_id(),"Section " + String(a),product,product,product);
46
+ }
47
+ product = Sub_Item.get_test_bind_item_sub_item(product);
48
+ return product;
49
+ };
50
+ const get_service_test = (title) =>{
51
+ let service = DataItem.get_new_full_item(
52
+ DataItem.get_new(DataType.SERVICE,Number.get_id()),
53
+ DataItem.get_new(DataType.SERVICE,0),
54
+ DataItem.get_new(DataType.SERVICE,0),
55
+ Field.get_test(title));
56
+ service = Sub_Item.get_test_bind_new_child(Number.get_id(),title,service,service,service);
57
+ service.cost = String(Number.get_id()) + "." + String(Number.get_id());
58
+ service.old_cost = String(Number.get_id()) + "." + String(Number.get_id());
59
+ service.type = "Type "+String(Number.get_id());
60
+ service.sub_type = "Sub Type "+String(Number.get_id());
61
+ service.stock = String(Number.get_id(3-1));
62
+ for(let a=0;a<10;a++){
63
+ service=Sub_Item.get_test_bind_new_child(Number.get_id(),"Section " + String(a),service,service,service);
64
+ }
65
+ service = Sub_Item.get_test_bind_item_sub_item(service);
66
+ return service;
67
+ };
68
+ const get_event_test = (title) =>{
69
+ let event = DataItem.get_new_full_item(
70
+ DataItem.get_new(DataType.EVENT,Number.get_id()),
71
+ DataItem.get_new(DataType.EVENT,0),
72
+ DataItem.get_new(DataType.EVENT,0),
73
+ Field.get_test(title));
74
+ event = Sub_Item.get_test_bind_new_child(Number.get_id(),title,event,event,event);
75
+ event.cost = String(Number.get_id()) + "." + String(Number.get_id());
76
+ event.old_cost = String(Number.get_id()) + "." + String(Number.get_id());
77
+ event.date = String(String(Number.get_id(2030)) + "-" + String(Number.get_id(13)) + "-" + String(Number.get_id(30))).trim();
78
+ event.time = String(Number.get_id(24)) + ":" + String(Number.get_id(59));
79
+ event.website = "Website "+String(Number.get_id());
80
+ event.location = "Location "+String(Number.get_id());
81
+ event.meeting_link = "Meeting Link "+String(Number.get_id());
82
+ event.stock = String(Number.get_id(3-1));
83
+ for(let a=0;a<10;a++){
84
+ event=Sub_Item.get_test_bind_new_child(Number.get_id(),"Section " + String(a),event,event,event);
85
+ }
86
+ event = Sub_Item.get_test_bind_item_sub_item(event);
87
+ return event;
88
+ };
89
+
90
+ const get_field_test = (title) =>{
91
+ let item = {
92
+ date_create:new moment().toISOString(),
93
+ date_save:new moment().toISOString(),
94
+ title:title,
95
+ setting_visible:"1",
96
+ photo_data:"/images/no_img.jpg",
97
+ title_url:Str.get_title_url(title),
98
+ sub_note : "Sub Note "+String(Number.get_id()),
99
+ note : "Note "+String(Number.get_id())
100
+ }
101
+ for(let b = 1;b<20;b++){
102
+ item['value_'+String(b)] = 'value ' + String(b);
103
+ }
104
+ return item;
105
+ }
106
+ module.exports = {
107
+ get_template_test,
108
+ get_page_test,
109
+ get_product_test,
110
+ get_service_test,
111
+ get_event_test
112
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "biz9-logic",
3
- "version": "4.0.20",
3
+ "version": "4.0.21",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"
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,Product,Service,Event,Template,Page} = require('./');
3
+ const {DataItem,DataType,Url,Obj,BiZ_Url,Cat,Stock,Schedule,Storage,Business,Product,Service,Event,Template,Page,Category} = require('./index');
4
4
  const {Log,Test,Number} = require('biz9-utility');
5
5
  const {Scriptz}= require('biz9-scriptz');
6
6
 
@@ -31,17 +31,40 @@ describe("connect", () => {
31
31
 
32
32
  function(call) {
33
33
  console.log('CONNECT-START');
34
+
35
+ /* --CONFIG--START */
34
36
  //let biz9_config = Scriptz.get_biz9_config({biz9_config_file:path.resolve('../../biz9_config')});
35
37
  //let cloud_url = Url.connect(biz9_config);
38
+ /* --CONFIG--END */
39
+
40
+
41
+ /* --DATA_TYPE--START */
42
+ //Log.w('data_type_list',DataType.get_item_list());
43
+ /* --DATA_TYPE--END */
44
+
45
+
46
+ /* --CATEGORY--START */
47
+ //Log.w("Category",Category.get_test("Category " + Number.get_id(),{get_items:false}));
48
+ //let category = Category.get_test_list_by_category();
49
+ /* --CATEGORY--END */
50
+
51
+
52
+ /* --PRODUCT--START */
53
+ //let product = Product.get_test_list_by_category();
54
+ //Log.w('product_test',Product.get_test("Product " + Number.get_id(),{get_items:false}));
55
+ Log.w('product_list_test',Product.get_test_list_by_category("Product " + Number.get_id(),{get_items:false}));
56
+ //console.log(Product.get_test("Product " + Number.get_id(),{get_items:false}));
57
+ /* --PRODUCT--END */
58
+
36
59
  //console.log(Template.get_test()); //get_template_test
37
60
  //console.log(Business.get_test()); // get_business_test
38
61
  // console.log(Page.get_test("Page " +String(Number.get_id()))); // get_page_test
39
- console.log(Page.get_test("Page " +String("Cool"))); // get_page_test
62
+ //console.log(Page.get_test("Page " +String("Cool"))); // get_page_test
40
63
  //console.log(Event.get_test());
41
64
  //console.log(Product.get_test("Product " +String(Number.get_id()))); // get_product_test
42
65
  //console.log(Service.get_test("Service " +String(Number.get_id()))); // get_service_test
43
66
  //console.log(Event.get_test("Event " +String(Number.get_id()))); // get_service_test
44
- //let product = Product.get_test();
67
+ //console.log(Category.get_test()); // get_category_test
45
68
  //console.log(product.section_1);
46
69
  //get page
47
70