biz9-logic 10.0.48 → 10.0.57
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 +2 -2
- package/index.js +36 -25
- package/package.json +1 -1
- package/test.js +1 -1
package/biz9_config
CHANGED
package/index.js
CHANGED
|
@@ -5,7 +5,7 @@ License GNU General Public License v3.0
|
|
|
5
5
|
Description: BiZ9 Framework: Logic-JS
|
|
6
6
|
*/
|
|
7
7
|
const moment = require('moment');
|
|
8
|
-
const {Str,Num,Obj} = require('biz9-utility');
|
|
8
|
+
const {Str,Num,Obj,Log} = require('biz9-utility');
|
|
9
9
|
class Message {
|
|
10
10
|
static SUCCESS="Success";
|
|
11
11
|
static CONFIRM="Are You Sure?";
|
|
@@ -93,7 +93,6 @@ class Type {
|
|
|
93
93
|
static FIELD_PARAM = 'param';
|
|
94
94
|
static FIELD_PARENT_DATA_TYPE='parent_data_type';
|
|
95
95
|
static FIELD_PARENT_ID='parent_id';
|
|
96
|
-
static FIELD_ROLE = 'role';
|
|
97
96
|
static FIELD_SOURCE='source';
|
|
98
97
|
static FIELD_SOURCE_DATA_TYPE='source_data_type';
|
|
99
98
|
static FIELD_SOURCE_KEY='source_key';
|
|
@@ -118,6 +117,7 @@ class Type {
|
|
|
118
117
|
static FIELD_USER_LAST_NAME = 'last_name';
|
|
119
118
|
static FIELD_USER_USERNAME = 'username';
|
|
120
119
|
static FIELD_USER_PASSWORD = 'password';
|
|
120
|
+
static FIELD_USER_ROLE = 'role';
|
|
121
121
|
static FIELD_USER_STATE = 'state';
|
|
122
122
|
static FIELD_VALUE = 'value';
|
|
123
123
|
static FIELD_WEBSITE = 'website';
|
|
@@ -1142,42 +1142,45 @@ class User_Logic {
|
|
|
1142
1142
|
};
|
|
1143
1143
|
}
|
|
1144
1144
|
class Data_Logic {
|
|
1145
|
-
static get = (data_type,id,option) => {
|
|
1146
|
-
return Data_Logic.get_new(data_type,id,option);
|
|
1147
|
-
};
|
|
1148
1145
|
static get_new = (data_type,id,option) => {
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1146
|
+
return Data_Logic.get(data_type,id,option);
|
|
1147
|
+
};
|
|
1148
|
+
// --> options / test / test_blank / title / generate_title / count
|
|
1149
|
+
static get = (data_type,id,option) => {
|
|
1150
|
+
function get_test_data(data_type){
|
|
1153
1151
|
switch(data_type)
|
|
1154
1152
|
{
|
|
1155
1153
|
case Type.DATA_BLOG_POST:
|
|
1156
|
-
|
|
1154
|
+
return Blog_Post_Logic.get_test();
|
|
1157
1155
|
break;
|
|
1158
1156
|
case Type.DATA_SERVICE:
|
|
1159
|
-
|
|
1157
|
+
return Service_Logic.get_test();
|
|
1160
1158
|
break;
|
|
1161
1159
|
case Type.DATA_EVENT:
|
|
1162
|
-
|
|
1163
|
-
|
|
1160
|
+
return Event_Logic.get_test();
|
|
1161
|
+
breaip
|
|
1164
1162
|
case Type.DATA_PRODUCT:
|
|
1165
|
-
|
|
1163
|
+
return Product_Logic.get_test();
|
|
1166
1164
|
break;
|
|
1167
1165
|
case Type.DATA_CONTENT:
|
|
1168
1166
|
case Type.DATA_CATEGORY:
|
|
1169
1167
|
case Type.DATA_BLANK:
|
|
1170
|
-
|
|
1168
|
+
return Blank_Logic.get_test();
|
|
1171
1169
|
break;
|
|
1172
1170
|
case Type.DATA_USER:
|
|
1173
|
-
|
|
1171
|
+
return User_Logic.get_test();
|
|
1174
1172
|
break;
|
|
1175
1173
|
default:
|
|
1176
|
-
|
|
1177
|
-
data.data_type = data_type;
|
|
1174
|
+
return Blank_Logic.get_test();
|
|
1178
1175
|
break;
|
|
1179
1176
|
}
|
|
1180
1177
|
}
|
|
1178
|
+
let data = {data_type:data_type,id:id};
|
|
1179
|
+
option = option ? option : {count:0};
|
|
1180
|
+
data = Field_Logic.get_base_option(data,option);
|
|
1181
|
+
if(option.test){
|
|
1182
|
+
data = Obj.merge(get_test_data(data_type),data);
|
|
1183
|
+
}
|
|
1181
1184
|
if(option.test_blank){
|
|
1182
1185
|
for(const field in data){
|
|
1183
1186
|
if(field != Type.FIELD_ID && field != Type.FIELD_DATA_TYPE){
|
|
@@ -1185,6 +1188,17 @@ class Data_Logic {
|
|
|
1185
1188
|
}
|
|
1186
1189
|
}
|
|
1187
1190
|
}
|
|
1191
|
+
if(option.count>1){
|
|
1192
|
+
let items = [];
|
|
1193
|
+
for(let a = 0;a<option.count;a++){
|
|
1194
|
+
let my_title = Type.get_data_type_by_type(data_type) + " " +Num.get_id(999);
|
|
1195
|
+
let test_data = Obj.merge(data,get_test_data(data.data_type));
|
|
1196
|
+
test_data[Type.FIELD_TITLE] = my_title;
|
|
1197
|
+
test_data[Type.FIELD_TITLE_URL] = Str.get_title_url(my_title);
|
|
1198
|
+
items.push(test_data);
|
|
1199
|
+
}
|
|
1200
|
+
data = items;
|
|
1201
|
+
}
|
|
1188
1202
|
return data;
|
|
1189
1203
|
};
|
|
1190
1204
|
static get_search = (data_type,filter,sort_by,page_current,page_size) => {
|
|
@@ -1195,8 +1209,9 @@ class Data_Logic {
|
|
|
1195
1209
|
let type = option.type ? option.type : Type.TITLE_ITEMS;
|
|
1196
1210
|
let field = option.field ? option.field : {};
|
|
1197
1211
|
let title = option.title ? option.title : {};
|
|
1198
|
-
let
|
|
1199
|
-
let
|
|
1212
|
+
let image_show = option.image_show ? option.image_show : {};
|
|
1213
|
+
let image = option.image ? option.image : {show:false};
|
|
1214
|
+
let page_current = option.page_current ? option.page_current : 1;
|
|
1200
1215
|
let page_size = option.page_size ? option.page_size : 0;
|
|
1201
1216
|
return {type:type,field:field,title:title,image:image,page_current:page_current,page_size:page_size};
|
|
1202
1217
|
}
|
|
@@ -1208,7 +1223,7 @@ class Data_Logic {
|
|
|
1208
1223
|
parent_field = parent_field ? parent_field : parent_field;
|
|
1209
1224
|
let field = option.field ? option.field : {};
|
|
1210
1225
|
let title = option.title ? option.title : Str.get_title_url(Type.get_data_type_by_type(foreign_data_type,{plural:true}));
|
|
1211
|
-
let page_current = option.page_current ? option.page_current :
|
|
1226
|
+
let page_current = option.page_current ? option.page_current : 1;
|
|
1212
1227
|
let page_size = option.page_size ? option.page_size : 0;
|
|
1213
1228
|
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};
|
|
1214
1229
|
}
|
|
@@ -1428,11 +1443,7 @@ class Url {
|
|
|
1428
1443
|
//cms
|
|
1429
1444
|
static CMS_DEMO_POST="cms/demo_post";
|
|
1430
1445
|
static CMS_GET="cms/get";
|
|
1431
|
-
static CMS_POST="cms/post";
|
|
1432
|
-
static CMS_ITEM_PARENT_TOP_TYPE_CATEGORY="cms/item_parent_top_type_category";
|
|
1433
1446
|
static CMS_SEARCH_ITEM_TYPE_CATEGORY="cms/search_item_type_category";
|
|
1434
|
-
//content
|
|
1435
|
-
static CONTENT="item/content";
|
|
1436
1447
|
//crud
|
|
1437
1448
|
static COPY="main/crud/copy";
|
|
1438
1449
|
static DELETE="main/crud/delete";
|
package/package.json
CHANGED
package/test.js
CHANGED
|
@@ -37,7 +37,7 @@ describe("connect", () => {
|
|
|
37
37
|
//let join = App_Logic.get_join({},'','',{});
|
|
38
38
|
// -->
|
|
39
39
|
//let data = Data_Logic.get(Type.DATA_BLANK,0,{test:true});
|
|
40
|
-
let data = Data_Logic.get(Type.DATA_PRODUCT,0,{test:true,parent:parent,data:{title:'cool',title_url:'cool'}});
|
|
40
|
+
let data = Data_Logic.get(Type.DATA_PRODUCT,0,{test:true,count:1,parent:parent,data:{title:'cool',title_url:'cool'}});
|
|
41
41
|
//let data = Data_Logic.get(Type.DATA_BLANK,0,{title:'cool bean',data:{field_1:'field_1',field_2:'field_2'}});
|
|
42
42
|
//let data = Data_Logic.get(Type.DATA_BLANK,0,{title:'cool bean'});
|
|
43
43
|
//let data = Data_Logic.get(Type.DATA_BLANK,0,{data:{field_1:'field_1',field_2:'field_2'}});
|