@fctc/widget-logic 1.1.4 → 1.1.5
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/dist/hooks.d.mts +919 -1
- package/dist/hooks.d.ts +919 -1
- package/dist/hooks.js +530 -9
- package/dist/hooks.mjs +544 -9
- package/dist/index.d.mts +65 -166
- package/dist/index.d.ts +65 -166
- package/dist/index.js +816 -231
- package/dist/index.mjs +801 -207
- package/dist/types.d.mts +4 -98
- package/dist/types.d.ts +4 -98
- package/dist/utils.d.mts +36 -0
- package/dist/utils.d.ts +36 -0
- package/dist/utils.js +277 -0
- package/dist/utils.mjs +239 -0
- package/package.json +66 -57
package/dist/index.js
CHANGED
|
@@ -4034,33 +4034,644 @@ var require_moment = __commonJS({
|
|
|
4034
4034
|
// src/index.ts
|
|
4035
4035
|
var index_exports = {};
|
|
4036
4036
|
__export(index_exports, {
|
|
4037
|
+
API_APP_URL: () => API_APP_URL,
|
|
4038
|
+
API_PRESCHOOL_URL: () => API_PRESCHOOL_URL,
|
|
4037
4039
|
CloseIcon: () => CloseIcon,
|
|
4038
4040
|
EyeIcon: () => EyeIcon,
|
|
4039
4041
|
LoadingIcon: () => LoadingIcon,
|
|
4042
|
+
STORAGES: () => STORAGES,
|
|
4040
4043
|
binaryFieldController: () => binaryFieldController,
|
|
4041
4044
|
colorFieldController: () => colorFieldController,
|
|
4042
|
-
|
|
4045
|
+
combineContexts: () => combineContexts,
|
|
4046
|
+
convertFieldsToArray: () => convertFieldsToArray,
|
|
4043
4047
|
copyLinkButtonController: () => copyLinkButtonController,
|
|
4048
|
+
countSum: () => countSum,
|
|
4044
4049
|
dateFieldController: () => dateFieldController,
|
|
4045
4050
|
downLoadBinaryController: () => downLoadBinaryController,
|
|
4046
4051
|
downloadFileController: () => downloadFileController,
|
|
4047
4052
|
durationController: () => durationController,
|
|
4048
4053
|
floatController: () => floatController,
|
|
4049
4054
|
floatTimeFiledController: () => floatTimeFiledController,
|
|
4055
|
+
getDateRange: () => getDateRange,
|
|
4056
|
+
languages: () => languages,
|
|
4050
4057
|
many2manyFieldController: () => many2manyFieldController,
|
|
4051
4058
|
many2manyTagsController: () => many2manyTagsController,
|
|
4052
4059
|
many2oneButtonController: () => many2oneButtonController,
|
|
4053
4060
|
many2oneFieldController: () => many2oneFieldController,
|
|
4061
|
+
mergeButtons: () => mergeButtons,
|
|
4054
4062
|
priorityFieldController: () => priorityFieldController,
|
|
4063
|
+
setStorageItemAsync: () => setStorageItemAsync,
|
|
4055
4064
|
statusDropdownController: () => statusDropdownController,
|
|
4065
|
+
useAuth: () => useAuth,
|
|
4066
|
+
useCallAction: () => useCallAction,
|
|
4056
4067
|
useClickOutside: () => useClickOutside,
|
|
4068
|
+
useConfig: () => useConfig,
|
|
4057
4069
|
useDebounce: () => useDebounce,
|
|
4058
|
-
|
|
4070
|
+
useDetail: () => useDetail,
|
|
4071
|
+
useGetRowIds: () => useGetRowIds,
|
|
4072
|
+
useListData: () => useListData,
|
|
4073
|
+
useMenu: () => useMenu,
|
|
4074
|
+
useProfile: () => useProfile,
|
|
4075
|
+
useStorageState: () => useStorageState,
|
|
4076
|
+
useUser: () => useUser,
|
|
4077
|
+
useViewV2: () => useViewV2
|
|
4059
4078
|
});
|
|
4060
4079
|
module.exports = __toCommonJS(index_exports);
|
|
4061
4080
|
|
|
4062
|
-
// src/hooks/use-
|
|
4081
|
+
// src/hooks/core/use-call-action.ts
|
|
4082
|
+
var import_interface_logic = require("@fctc/interface-logic");
|
|
4063
4083
|
var import_react = require("react");
|
|
4084
|
+
var useCallAction = () => {
|
|
4085
|
+
const queryLoadAction = (0, import_interface_logic.useLoadAction)();
|
|
4086
|
+
const queryRunAction = (0, import_interface_logic.useRunAction)();
|
|
4087
|
+
const [data, setData] = (0, import_react.useState)(void 0);
|
|
4088
|
+
const callAction = async ({
|
|
4089
|
+
aid,
|
|
4090
|
+
actionType = "ir.actions.act_window"
|
|
4091
|
+
}) => {
|
|
4092
|
+
const context = (0, import_interface_logic.getEnv)().context;
|
|
4093
|
+
let res = void 0;
|
|
4094
|
+
if (actionType === "ir.actions.act_window") {
|
|
4095
|
+
res = await queryLoadAction.mutateAsync({
|
|
4096
|
+
idAction: aid,
|
|
4097
|
+
context
|
|
4098
|
+
});
|
|
4099
|
+
} else if (actionType === "ir.actions.server") {
|
|
4100
|
+
res = await queryRunAction.mutateAsync({
|
|
4101
|
+
idAction: aid,
|
|
4102
|
+
context
|
|
4103
|
+
});
|
|
4104
|
+
}
|
|
4105
|
+
setData(res);
|
|
4106
|
+
return res;
|
|
4107
|
+
};
|
|
4108
|
+
return [data, callAction];
|
|
4109
|
+
};
|
|
4110
|
+
|
|
4111
|
+
// src/hooks/core/use-config.ts
|
|
4112
|
+
var import_interface_logic2 = require("@fctc/interface-logic");
|
|
4113
|
+
var import_react2 = require("react");
|
|
4114
|
+
var useConfig = ({ localStorageUtils, sessionStorageUtils }) => {
|
|
4115
|
+
const dispatch = (0, import_interface_logic2.useAppDispatch)();
|
|
4116
|
+
const envConfig = (0, import_react2.useMemo)(() => {
|
|
4117
|
+
return {
|
|
4118
|
+
mode: "development",
|
|
4119
|
+
baseUrl: "https://api.vitrust.app/c2/api/v2",
|
|
4120
|
+
config: {
|
|
4121
|
+
grantType: "password",
|
|
4122
|
+
clientId: "C52foVQSMpnNOcAP2CBIIkupOSfxUarF8nlOPfXM",
|
|
4123
|
+
clientSecret: "rColINr4a9QBFQPqQB8YU1XfBjqzwerDMJGBxsFK"
|
|
4124
|
+
}
|
|
4125
|
+
};
|
|
4126
|
+
}, []);
|
|
4127
|
+
const config = (0, import_react2.useMemo)(() => {
|
|
4128
|
+
return {
|
|
4129
|
+
VITE_SIDEBAR_TYPE: "grid/sidebar",
|
|
4130
|
+
VITE_APP_DOMAIN: "https://api.vitrust.app/c2/",
|
|
4131
|
+
VITE_IS_EDU: true,
|
|
4132
|
+
VITE_LOGO_WHITE_LOGIN: "https://static.vitrust.app/vitrust/3a/3a1301f614dea6ee19ebf99b68f57e3fd46011d2.png",
|
|
4133
|
+
VITE_LOGO_BLACK_LOGIN: "https://static.vitrust.app/vitrust/32/3223918780da7a439f916faac9abf0bfe98dfa07.png",
|
|
4134
|
+
VITE_BACKGROUND_SIDEBAR: "linear-gradient(178deg, rgb(1, 106, 13) -0.89%, rgb(4, 179, 66) 99.46%",
|
|
4135
|
+
VITE_BANNER: "https://static.vitrust.app/vitrust/5d/5d20cab0627182b4ed5cba4ee42c58b98b663e5b.svg",
|
|
4136
|
+
VITE_BG_BUTTON: "#008F3C",
|
|
4137
|
+
VITE_BACKGROUND_PAGE: "#F9FAFB"
|
|
4138
|
+
};
|
|
4139
|
+
}, []);
|
|
4140
|
+
(0, import_react2.useEffect)(() => {
|
|
4141
|
+
try {
|
|
4142
|
+
const env = (0, import_interface_logic2.getEnv)();
|
|
4143
|
+
env.setupEnv({
|
|
4144
|
+
baseUrl: envConfig.baseUrl,
|
|
4145
|
+
port: 3e3,
|
|
4146
|
+
config: {
|
|
4147
|
+
grantType: envConfig.config.grantType,
|
|
4148
|
+
clientId: envConfig.config.clientId,
|
|
4149
|
+
clientSecret: envConfig.config.clientSecret
|
|
4150
|
+
},
|
|
4151
|
+
db: "preschool",
|
|
4152
|
+
localStorageUtils: localStorageUtils(),
|
|
4153
|
+
sessionStorageUtils: sessionStorageUtils()
|
|
4154
|
+
});
|
|
4155
|
+
dispatch((0, import_interface_logic2.setEnvFile)(config));
|
|
4156
|
+
} catch (error) {
|
|
4157
|
+
console.error("Error loading env or config:", error);
|
|
4158
|
+
}
|
|
4159
|
+
}, [dispatch, envConfig, config]);
|
|
4160
|
+
return { envConfig, config };
|
|
4161
|
+
};
|
|
4162
|
+
|
|
4163
|
+
// src/hooks/core/use-detail.ts
|
|
4164
|
+
var import_interface_logic3 = require("@fctc/interface-logic");
|
|
4165
|
+
var import_react_query = require("@tanstack/react-query");
|
|
4166
|
+
var import_react3 = require("react");
|
|
4167
|
+
var useDetail = (accessToken, sub) => {
|
|
4168
|
+
const dispatch = (0, import_interface_logic3.useAppDispatch)();
|
|
4169
|
+
const fetchGetDetail = (0, import_interface_logic3.useGetDetail)();
|
|
4170
|
+
const userDetailQuery = (0, import_react_query.useQuery)({
|
|
4171
|
+
queryKey: ["userDetailQuery", sub && accessToken],
|
|
4172
|
+
queryFn: () => {
|
|
4173
|
+
return fetchGetDetail.mutateAsync({
|
|
4174
|
+
model: "res.users",
|
|
4175
|
+
ids: [sub],
|
|
4176
|
+
specification: { image_256: {} }
|
|
4177
|
+
});
|
|
4178
|
+
},
|
|
4179
|
+
enabled: !!sub && !!accessToken
|
|
4180
|
+
});
|
|
4181
|
+
(0, import_react3.useEffect)(() => {
|
|
4182
|
+
if (userDetailQuery.data) {
|
|
4183
|
+
const userPicture = userDetailQuery.data;
|
|
4184
|
+
dispatch(
|
|
4185
|
+
(0, import_interface_logic3.setProfile)({ ...userPicture, image: userPicture?.[0]?.image_256 })
|
|
4186
|
+
);
|
|
4187
|
+
}
|
|
4188
|
+
}, [userDetailQuery.data, dispatch]);
|
|
4189
|
+
return userDetailQuery;
|
|
4190
|
+
};
|
|
4191
|
+
|
|
4192
|
+
// src/hooks/core/use-list-data.ts
|
|
4193
|
+
var import_react5 = require("react");
|
|
4194
|
+
var import_interface_logic4 = require("@fctc/interface-logic");
|
|
4195
|
+
|
|
4196
|
+
// src/utils/function.ts
|
|
4197
|
+
var import_react4 = require("react");
|
|
4198
|
+
var countSum = (data, field) => {
|
|
4199
|
+
if (!data || !field) return 0;
|
|
4200
|
+
return data.reduce(
|
|
4201
|
+
(total, item) => total + (item?.[`${field}_count`] || 0),
|
|
4202
|
+
0
|
|
4203
|
+
);
|
|
4204
|
+
};
|
|
4205
|
+
function mergeButtons(fields) {
|
|
4206
|
+
const buttons = fields?.filter((f) => f.type_co === "button");
|
|
4207
|
+
const others = fields?.filter((f) => f.type_co !== "button");
|
|
4208
|
+
if (buttons?.length) {
|
|
4209
|
+
others.push({
|
|
4210
|
+
type_co: "buttons",
|
|
4211
|
+
buttons
|
|
4212
|
+
});
|
|
4213
|
+
}
|
|
4214
|
+
return others;
|
|
4215
|
+
}
|
|
4216
|
+
function isElementVisible(el) {
|
|
4217
|
+
const style = window.getComputedStyle(el);
|
|
4218
|
+
return style.display !== "none" && style.visibility !== "hidden" && style.opacity !== "0";
|
|
4219
|
+
}
|
|
4220
|
+
function arraysAreEqual(a, b) {
|
|
4221
|
+
if (a.length !== b.length) return false;
|
|
4222
|
+
const setA = new Set(a);
|
|
4223
|
+
const setB = new Set(b);
|
|
4224
|
+
if (setA.size !== setB.size) return false;
|
|
4225
|
+
for (const val of setA) {
|
|
4226
|
+
if (!setB.has(val)) return false;
|
|
4227
|
+
}
|
|
4228
|
+
return true;
|
|
4229
|
+
}
|
|
4230
|
+
function useGetRowIds(tableRef) {
|
|
4231
|
+
const [rowIds, setRowIds] = (0, import_react4.useState)([]);
|
|
4232
|
+
const lastRowIdsRef = (0, import_react4.useRef)([]);
|
|
4233
|
+
const updateVisibleRowIds = (0, import_react4.useCallback)(() => {
|
|
4234
|
+
const table = tableRef?.current;
|
|
4235
|
+
if (!table) return;
|
|
4236
|
+
const rows = table.querySelectorAll("tr[data-row-id]");
|
|
4237
|
+
const ids = [];
|
|
4238
|
+
rows.forEach((row) => {
|
|
4239
|
+
const el = row;
|
|
4240
|
+
if (isElementVisible(el)) {
|
|
4241
|
+
const id = el.getAttribute("data-row-id");
|
|
4242
|
+
if (id) ids.push(id);
|
|
4243
|
+
}
|
|
4244
|
+
});
|
|
4245
|
+
const uniqueIds = Array.from(new Set(ids));
|
|
4246
|
+
if (!arraysAreEqual(lastRowIdsRef.current, uniqueIds)) {
|
|
4247
|
+
lastRowIdsRef.current = uniqueIds;
|
|
4248
|
+
setRowIds(uniqueIds);
|
|
4249
|
+
}
|
|
4250
|
+
}, [tableRef]);
|
|
4251
|
+
(0, import_react4.useEffect)(() => {
|
|
4252
|
+
const table = tableRef?.current;
|
|
4253
|
+
if (!table) return;
|
|
4254
|
+
const observer = new MutationObserver(() => {
|
|
4255
|
+
updateVisibleRowIds();
|
|
4256
|
+
});
|
|
4257
|
+
observer.observe(table, {
|
|
4258
|
+
childList: true,
|
|
4259
|
+
subtree: true,
|
|
4260
|
+
attributes: true,
|
|
4261
|
+
attributeFilter: ["style", "class"]
|
|
4262
|
+
});
|
|
4263
|
+
updateVisibleRowIds();
|
|
4264
|
+
return () => {
|
|
4265
|
+
observer.disconnect();
|
|
4266
|
+
};
|
|
4267
|
+
}, [updateVisibleRowIds, tableRef]);
|
|
4268
|
+
return { rowIds, refresh: updateVisibleRowIds };
|
|
4269
|
+
}
|
|
4270
|
+
var getDateRange = (currentDate, unit) => {
|
|
4271
|
+
const date = new Date(currentDate);
|
|
4272
|
+
let dateStart, dateEnd;
|
|
4273
|
+
function formatDate(d) {
|
|
4274
|
+
return d.getFullYear() + "-" + String(d.getMonth() + 1).padStart(2, "0") + "-" + String(d.getDate()).padStart(2, "0") + " " + String(d.getHours()).padStart(2, "0") + ":" + String(d.getMinutes()).padStart(2, "0") + ":" + String(d.getSeconds()).padStart(2, "0");
|
|
4275
|
+
}
|
|
4276
|
+
switch (unit) {
|
|
4277
|
+
case "month":
|
|
4278
|
+
dateStart = new Date(
|
|
4279
|
+
date.getFullYear(),
|
|
4280
|
+
date.getMonth() + 1,
|
|
4281
|
+
date.getDate(),
|
|
4282
|
+
23,
|
|
4283
|
+
59,
|
|
4284
|
+
59
|
|
4285
|
+
);
|
|
4286
|
+
dateStart.setHours(dateStart.getHours() - 7);
|
|
4287
|
+
dateEnd = new Date(date.getFullYear(), date.getMonth(), 0, 0, 0, 0);
|
|
4288
|
+
dateEnd.setHours(dateEnd.getHours() - 7);
|
|
4289
|
+
break;
|
|
4290
|
+
case "day":
|
|
4291
|
+
dateStart = new Date(
|
|
4292
|
+
date.getFullYear(),
|
|
4293
|
+
date.getMonth(),
|
|
4294
|
+
date.getDate(),
|
|
4295
|
+
23,
|
|
4296
|
+
59,
|
|
4297
|
+
59
|
|
4298
|
+
);
|
|
4299
|
+
dateStart.setHours(dateStart.getHours() - 7);
|
|
4300
|
+
dateEnd = new Date(
|
|
4301
|
+
date.getFullYear(),
|
|
4302
|
+
date.getMonth(),
|
|
4303
|
+
date.getDate(),
|
|
4304
|
+
0,
|
|
4305
|
+
0,
|
|
4306
|
+
0
|
|
4307
|
+
);
|
|
4308
|
+
dateEnd.setHours(dateEnd.getHours() - 7);
|
|
4309
|
+
break;
|
|
4310
|
+
case "week":
|
|
4311
|
+
const dayOfWeek = date.getDay();
|
|
4312
|
+
const daysToMonday = dayOfWeek === 0 ? -6 : 1 - dayOfWeek;
|
|
4313
|
+
const daysToSunday = dayOfWeek === 0 ? 0 : 7 - dayOfWeek;
|
|
4314
|
+
dateStart = new Date(
|
|
4315
|
+
date.getFullYear(),
|
|
4316
|
+
date.getMonth(),
|
|
4317
|
+
date.getDate() + daysToSunday,
|
|
4318
|
+
23,
|
|
4319
|
+
59,
|
|
4320
|
+
59
|
|
4321
|
+
);
|
|
4322
|
+
dateStart.setHours(dateStart.getHours() - 7);
|
|
4323
|
+
dateEnd = new Date(
|
|
4324
|
+
date.getFullYear(),
|
|
4325
|
+
date.getMonth(),
|
|
4326
|
+
date.getDate() + daysToMonday,
|
|
4327
|
+
0,
|
|
4328
|
+
0,
|
|
4329
|
+
0
|
|
4330
|
+
);
|
|
4331
|
+
dateEnd.setHours(dateEnd.getHours() - 7);
|
|
4332
|
+
break;
|
|
4333
|
+
case "year":
|
|
4334
|
+
dateStart = new Date(date.getFullYear(), 11, 31, 23, 59, 59);
|
|
4335
|
+
dateStart.setHours(dateStart.getHours() - 7);
|
|
4336
|
+
dateEnd = new Date(date.getFullYear() - 1, 11, 31, 0, 0, 0);
|
|
4337
|
+
dateEnd.setHours(dateEnd.getHours() - 7);
|
|
4338
|
+
break;
|
|
4339
|
+
default:
|
|
4340
|
+
throw new Error(
|
|
4341
|
+
"\u0110\u01A1n v\u1ECB kh\xF4ng h\u1EE3p l\u1EC7. Ch\u1EC9 ch\u1EA5p nh\u1EADn: week, day, month, year"
|
|
4342
|
+
);
|
|
4343
|
+
}
|
|
4344
|
+
return [
|
|
4345
|
+
["date_start", "<=", formatDate(dateStart)],
|
|
4346
|
+
["date_end", ">=", formatDate(dateEnd)]
|
|
4347
|
+
];
|
|
4348
|
+
};
|
|
4349
|
+
var convertFieldsToArray = (fields) => {
|
|
4350
|
+
const defaultFields = ["display_name", "date_start", "date_end"];
|
|
4351
|
+
if (!fields || !Array.isArray(fields)) {
|
|
4352
|
+
return defaultFields;
|
|
4353
|
+
}
|
|
4354
|
+
const inputFields = fields.filter((field) => field && field.type_co === "field").map((field) => field.name);
|
|
4355
|
+
return [...defaultFields, ...inputFields];
|
|
4356
|
+
};
|
|
4357
|
+
function combineContexts(contexts) {
|
|
4358
|
+
if (contexts.some((context) => !context)) {
|
|
4359
|
+
return void 0;
|
|
4360
|
+
} else {
|
|
4361
|
+
const res = contexts.reduce((acc, context) => {
|
|
4362
|
+
return { ...acc, ...context };
|
|
4363
|
+
}, {});
|
|
4364
|
+
return res;
|
|
4365
|
+
}
|
|
4366
|
+
}
|
|
4367
|
+
var STORAGES = {
|
|
4368
|
+
TOKEN: "accessToken",
|
|
4369
|
+
USER_INFO: "USER_INFO"
|
|
4370
|
+
};
|
|
4371
|
+
function useAsyncState(initialValue = [true, null]) {
|
|
4372
|
+
return (0, import_react4.useReducer)(
|
|
4373
|
+
(_state, action = null) => [false, action],
|
|
4374
|
+
initialValue
|
|
4375
|
+
);
|
|
4376
|
+
}
|
|
4377
|
+
async function setStorageItemAsync(key, value) {
|
|
4378
|
+
try {
|
|
4379
|
+
if (value === null) {
|
|
4380
|
+
localStorage.removeItem(key);
|
|
4381
|
+
} else {
|
|
4382
|
+
localStorage.setItem(key, value);
|
|
4383
|
+
}
|
|
4384
|
+
} catch (e) {
|
|
4385
|
+
console.error("Local storage is unavailable:", e);
|
|
4386
|
+
}
|
|
4387
|
+
}
|
|
4388
|
+
function useStorageState(key) {
|
|
4389
|
+
const [state, setState] = useAsyncState();
|
|
4390
|
+
(0, import_react4.useEffect)(() => {
|
|
4391
|
+
try {
|
|
4392
|
+
const storedValue = localStorage.getItem(key);
|
|
4393
|
+
setState(storedValue);
|
|
4394
|
+
} catch (e) {
|
|
4395
|
+
console.error("Local storage is unavailable:", e);
|
|
4396
|
+
}
|
|
4397
|
+
}, [key]);
|
|
4398
|
+
const setValue = (0, import_react4.useCallback)(
|
|
4399
|
+
(value) => {
|
|
4400
|
+
setState(value);
|
|
4401
|
+
setStorageItemAsync(key, value);
|
|
4402
|
+
},
|
|
4403
|
+
[key]
|
|
4404
|
+
);
|
|
4405
|
+
return [state, setValue];
|
|
4406
|
+
}
|
|
4407
|
+
|
|
4408
|
+
// src/hooks/core/use-list-data.ts
|
|
4409
|
+
var useListData = ({
|
|
4410
|
+
action,
|
|
4411
|
+
context,
|
|
4412
|
+
viewResponse
|
|
4413
|
+
}) => {
|
|
4414
|
+
const { groupByDomain } = (0, import_interface_logic4.useAppSelector)(import_interface_logic4.selectSearch);
|
|
4415
|
+
const initModel = (0, import_interface_logic4.useModel)();
|
|
4416
|
+
const [type, setType] = (0, import_react5.useState)("list");
|
|
4417
|
+
const [mode, setMode] = (0, import_react5.useState)("month");
|
|
4418
|
+
const [currentDate, setCurrentDate] = (0, import_react5.useState)(/* @__PURE__ */ new Date());
|
|
4419
|
+
const { pageLimit, page, order } = (0, import_interface_logic4.useAppSelector)(import_interface_logic4.selectList);
|
|
4420
|
+
const listDataProps = (0, import_react5.useMemo)(() => {
|
|
4421
|
+
const actData = action?.result;
|
|
4422
|
+
if (!viewResponse || !actData || !context) {
|
|
4423
|
+
return null;
|
|
4424
|
+
}
|
|
4425
|
+
const specification = initModel.initModel({
|
|
4426
|
+
name: String(actData.res_model),
|
|
4427
|
+
view: viewResponse || {},
|
|
4428
|
+
actContext: context,
|
|
4429
|
+
fields: type === "kanban" ? viewResponse?.views?.kanban?.fields : type === "calendar" ? viewResponse?.views?.calendar?.fields : viewResponse?.views?.list?.fields
|
|
4430
|
+
}).getSpecification();
|
|
4431
|
+
const domain = type === "calendar" ? getDateRange(currentDate, mode) : actData?.domain ? Array.isArray(actData?.domain) ? [...actData?.domain] : (0, import_interface_logic4.evalJSONDomain)(actData?.domain, context) : [];
|
|
4432
|
+
const limit = type === "calendar" ? 2500 : pageLimit;
|
|
4433
|
+
const offset = page * pageLimit;
|
|
4434
|
+
const fields = type === "calendar" ? convertFieldsToArray(viewResponse?.views?.calendar?.fields) || [] : typeof groupByDomain === "object" ? groupByDomain?.fields : void 0;
|
|
4435
|
+
const groupby = typeof groupByDomain === "object" ? [groupByDomain?.contexts?.[0]?.group_by] : [];
|
|
4436
|
+
const sort = order ? order : viewResponse?.views?.list?.default_order ? (0, import_interface_logic4.formatSortingString)(viewResponse?.views?.list?.default_order) : "";
|
|
4437
|
+
return {
|
|
4438
|
+
model: actData.res_model,
|
|
4439
|
+
specification,
|
|
4440
|
+
domain,
|
|
4441
|
+
limit,
|
|
4442
|
+
offset,
|
|
4443
|
+
fields,
|
|
4444
|
+
groupby,
|
|
4445
|
+
context,
|
|
4446
|
+
sort,
|
|
4447
|
+
type
|
|
4448
|
+
};
|
|
4449
|
+
}, [
|
|
4450
|
+
action?.result,
|
|
4451
|
+
context,
|
|
4452
|
+
currentDate,
|
|
4453
|
+
groupByDomain,
|
|
4454
|
+
initModel,
|
|
4455
|
+
mode,
|
|
4456
|
+
order,
|
|
4457
|
+
page,
|
|
4458
|
+
pageLimit,
|
|
4459
|
+
type,
|
|
4460
|
+
viewResponse
|
|
4461
|
+
]);
|
|
4462
|
+
const list = (0, import_interface_logic4.useGetListData)(
|
|
4463
|
+
listDataProps,
|
|
4464
|
+
[listDataProps],
|
|
4465
|
+
!!listDataProps
|
|
4466
|
+
);
|
|
4467
|
+
return {
|
|
4468
|
+
...list,
|
|
4469
|
+
state: {
|
|
4470
|
+
type,
|
|
4471
|
+
setType,
|
|
4472
|
+
mode,
|
|
4473
|
+
setMode,
|
|
4474
|
+
currentDate,
|
|
4475
|
+
setCurrentDate
|
|
4476
|
+
}
|
|
4477
|
+
};
|
|
4478
|
+
};
|
|
4479
|
+
|
|
4480
|
+
// src/hooks/core/use-menu.ts
|
|
4481
|
+
var import_react6 = require("react");
|
|
4482
|
+
var import_interface_logic5 = require("@fctc/interface-logic");
|
|
4483
|
+
|
|
4484
|
+
// src/utils/constants.ts
|
|
4485
|
+
var languages = [
|
|
4486
|
+
{ id: "vi_VN", name: "VIE" },
|
|
4487
|
+
{ id: "en_US", name: "ENG" }
|
|
4488
|
+
];
|
|
4489
|
+
var API_PRESCHOOL_URL = {
|
|
4490
|
+
baseURL: "https://preschool.vitrust.app"
|
|
4491
|
+
};
|
|
4492
|
+
var API_APP_URL = {
|
|
4493
|
+
baseUrl: "https://api.vitrust.app",
|
|
4494
|
+
c2: "https://api.vitrust.app/c2",
|
|
4495
|
+
apiV2: "https://api.vitrust.app/c2/api/v2"
|
|
4496
|
+
};
|
|
4497
|
+
|
|
4498
|
+
// src/hooks/core/use-menu.ts
|
|
4499
|
+
var useMenu = ({ context }) => {
|
|
4500
|
+
const menuData = (0, import_interface_logic5.useGetMenu)(context, !!context);
|
|
4501
|
+
const [menuid, setMenuId] = (0, import_react6.useState)(void 0);
|
|
4502
|
+
const [action, setAction] = useCallAction();
|
|
4503
|
+
const configedIconData = (0, import_react6.useMemo)(() => {
|
|
4504
|
+
const data = menuData.data;
|
|
4505
|
+
return data?.map((item) => {
|
|
4506
|
+
return {
|
|
4507
|
+
...item,
|
|
4508
|
+
child_id: item?.child_id?.map((child) => {
|
|
4509
|
+
return {
|
|
4510
|
+
...child,
|
|
4511
|
+
url_icon: API_APP_URL.c2 + "/" + child.url_icon
|
|
4512
|
+
};
|
|
4513
|
+
}) ?? [],
|
|
4514
|
+
url_icon: API_APP_URL.c2 + "/" + item.url_icon
|
|
4515
|
+
};
|
|
4516
|
+
});
|
|
4517
|
+
}, [menuData.data]);
|
|
4518
|
+
const handleChangeMenu = async ({
|
|
4519
|
+
menu,
|
|
4520
|
+
subMenu
|
|
4521
|
+
}) => {
|
|
4522
|
+
const aid = subMenu?.action?.id?.id;
|
|
4523
|
+
const actionType = subMenu?.action?.type;
|
|
4524
|
+
await setAction({
|
|
4525
|
+
aid: Number(aid),
|
|
4526
|
+
actionType
|
|
4527
|
+
});
|
|
4528
|
+
if (menu) {
|
|
4529
|
+
setMenuId(menu.id?.toString() ?? "");
|
|
4530
|
+
}
|
|
4531
|
+
};
|
|
4532
|
+
(0, import_react6.useEffect)(() => {
|
|
4533
|
+
const firstRecord = configedIconData?.[0];
|
|
4534
|
+
const firstChild = firstRecord?.child_id?.[0];
|
|
4535
|
+
if (firstChild && firstRecord) {
|
|
4536
|
+
handleChangeMenu({ menu: firstRecord, subMenu: firstChild });
|
|
4537
|
+
}
|
|
4538
|
+
}, [configedIconData]);
|
|
4539
|
+
return {
|
|
4540
|
+
...menuData,
|
|
4541
|
+
data: configedIconData,
|
|
4542
|
+
action: { handleChangeMenu },
|
|
4543
|
+
state: { menuid, action },
|
|
4544
|
+
context
|
|
4545
|
+
};
|
|
4546
|
+
};
|
|
4547
|
+
|
|
4548
|
+
// src/hooks/core/use-profile.ts
|
|
4549
|
+
var import_react_query2 = require("@tanstack/react-query");
|
|
4550
|
+
var import_react7 = require("react");
|
|
4551
|
+
var import_react_i18next = require("react-i18next");
|
|
4552
|
+
var import_interface_logic6 = require("@fctc/interface-logic");
|
|
4553
|
+
var useProfile = (accessToken) => {
|
|
4554
|
+
const getProfile = (0, import_interface_logic6.useGetProfile)();
|
|
4555
|
+
const dispatch = (0, import_interface_logic6.useAppDispatch)();
|
|
4556
|
+
const { i18n: i18n2 } = (0, import_react_i18next.useTranslation)();
|
|
4557
|
+
const fetchUserProfile = async () => {
|
|
4558
|
+
return await getProfile.mutateAsync();
|
|
4559
|
+
};
|
|
4560
|
+
const userInfoQuery = (0, import_react_query2.useQuery)({
|
|
4561
|
+
queryKey: ["userInfo", accessToken],
|
|
4562
|
+
queryFn: fetchUserProfile,
|
|
4563
|
+
enabled: !!accessToken
|
|
4564
|
+
});
|
|
4565
|
+
(0, import_react7.useEffect)(() => {
|
|
4566
|
+
if (userInfoQuery.data) {
|
|
4567
|
+
const userInfo = userInfoQuery.data;
|
|
4568
|
+
const env = (0, import_interface_logic6.getEnv)();
|
|
4569
|
+
env.setUid(userInfo?.sub);
|
|
4570
|
+
dispatch((0, import_interface_logic6.setDataUser)(userInfo));
|
|
4571
|
+
const userLocale = languages.find((lang) => lang?.id === userInfo?.locale);
|
|
4572
|
+
env.setLang(userLocale?.id);
|
|
4573
|
+
i18n2.changeLanguage(userLocale?.id.split("_")[0]);
|
|
4574
|
+
}
|
|
4575
|
+
}, [dispatch, userInfoQuery.data]);
|
|
4576
|
+
const context = (0, import_react7.useMemo)(() => {
|
|
4577
|
+
if (userInfoQuery.data?.sub && userInfoQuery.data?.locale) {
|
|
4578
|
+
return {
|
|
4579
|
+
uid: Number(userInfoQuery.data.sub),
|
|
4580
|
+
allowed_company_ids: [],
|
|
4581
|
+
lang: String(userInfoQuery.data.locale),
|
|
4582
|
+
tz: "Asia/Saigon"
|
|
4583
|
+
};
|
|
4584
|
+
}
|
|
4585
|
+
return void 0;
|
|
4586
|
+
}, [userInfoQuery.data]);
|
|
4587
|
+
return { ...userInfoQuery, context };
|
|
4588
|
+
};
|
|
4589
|
+
|
|
4590
|
+
// src/hooks/core/use-user.ts
|
|
4591
|
+
var useUser = (accessToken) => {
|
|
4592
|
+
const userProfile = useProfile(accessToken);
|
|
4593
|
+
const userDetail = useDetail(accessToken, userProfile.data?.sub);
|
|
4594
|
+
return { userProfile, userDetail, context: userProfile.context };
|
|
4595
|
+
};
|
|
4596
|
+
|
|
4597
|
+
// src/hooks/core/use-view-v2.ts
|
|
4598
|
+
var import_react8 = require("react");
|
|
4599
|
+
var import_interface_logic7 = require("@fctc/interface-logic");
|
|
4600
|
+
var useViewV2 = ({
|
|
4601
|
+
action,
|
|
4602
|
+
context
|
|
4603
|
+
}) => {
|
|
4604
|
+
const viewParams = (0, import_react8.useMemo)(() => {
|
|
4605
|
+
if (!action?.result) {
|
|
4606
|
+
return void 0;
|
|
4607
|
+
}
|
|
4608
|
+
const actionResult = action?.result;
|
|
4609
|
+
return {
|
|
4610
|
+
model: String(actionResult?.res_model),
|
|
4611
|
+
views: [
|
|
4612
|
+
...Array.isArray(actionResult?.views) ? actionResult?.views.map(
|
|
4613
|
+
(view2) => view2[1] === "list" ? [view2[0], "list"] : view2
|
|
4614
|
+
) : [],
|
|
4615
|
+
[
|
|
4616
|
+
Array.isArray(actionResult?.search_view_id) ? actionResult?.search_view_id[0] : actionResult?.search_view_id,
|
|
4617
|
+
"search"
|
|
4618
|
+
]
|
|
4619
|
+
],
|
|
4620
|
+
context
|
|
4621
|
+
};
|
|
4622
|
+
}, [action, context]);
|
|
4623
|
+
const view = (0, import_interface_logic7.useGetView)(
|
|
4624
|
+
viewParams || {},
|
|
4625
|
+
!!viewParams
|
|
4626
|
+
);
|
|
4627
|
+
return {
|
|
4628
|
+
...view,
|
|
4629
|
+
context
|
|
4630
|
+
};
|
|
4631
|
+
};
|
|
4632
|
+
|
|
4633
|
+
// src/hooks/core/use-auth.ts
|
|
4634
|
+
var import_interface_logic8 = require("@fctc/interface-logic");
|
|
4635
|
+
var useAuth = () => {
|
|
4636
|
+
const [[isLoading, accessToken], setAccessToken] = useStorageState("TOKEN");
|
|
4637
|
+
const loginMutate = (0, import_interface_logic8.useLoginCredential)();
|
|
4638
|
+
const dispatch = (0, import_interface_logic8.useAppDispatch)();
|
|
4639
|
+
const signIn = async (email, password) => {
|
|
4640
|
+
try {
|
|
4641
|
+
loginMutate.mutate(
|
|
4642
|
+
{
|
|
4643
|
+
email,
|
|
4644
|
+
password,
|
|
4645
|
+
path: "/authentication/oauth2/token"
|
|
4646
|
+
},
|
|
4647
|
+
{
|
|
4648
|
+
onSuccess: (res) => {
|
|
4649
|
+
setAccessToken(res.access_token);
|
|
4650
|
+
},
|
|
4651
|
+
onError: (err) => {
|
|
4652
|
+
}
|
|
4653
|
+
}
|
|
4654
|
+
);
|
|
4655
|
+
} catch (error) {
|
|
4656
|
+
throw new Error("Login failed");
|
|
4657
|
+
}
|
|
4658
|
+
};
|
|
4659
|
+
const signOut = async () => {
|
|
4660
|
+
dispatch((0, import_interface_logic8.setMenuList)([]));
|
|
4661
|
+
dispatch((0, import_interface_logic8.setDataUser)({}));
|
|
4662
|
+
dispatch((0, import_interface_logic8.setProfile)({}));
|
|
4663
|
+
setAccessToken(null);
|
|
4664
|
+
};
|
|
4665
|
+
return {
|
|
4666
|
+
signIn,
|
|
4667
|
+
signOut,
|
|
4668
|
+
accessToken,
|
|
4669
|
+
isLoading
|
|
4670
|
+
};
|
|
4671
|
+
};
|
|
4672
|
+
|
|
4673
|
+
// src/hooks/utils/use-click-outside.ts
|
|
4674
|
+
var import_react9 = require("react");
|
|
4064
4675
|
var DEFAULT_EVENTS = ["mousedown", "touchstart"];
|
|
4065
4676
|
var useClickOutside = ({
|
|
4066
4677
|
handler,
|
|
@@ -4068,8 +4679,8 @@ var useClickOutside = ({
|
|
|
4068
4679
|
nodes = [],
|
|
4069
4680
|
refs
|
|
4070
4681
|
}) => {
|
|
4071
|
-
const ref = (0,
|
|
4072
|
-
(0,
|
|
4682
|
+
const ref = (0, import_react9.useRef)(null);
|
|
4683
|
+
(0, import_react9.useEffect)(() => {
|
|
4073
4684
|
const listener = (event) => {
|
|
4074
4685
|
const { target } = event;
|
|
4075
4686
|
if (refs && refs?.length > 0 && refs?.some((r) => r.current?.contains(target))) {
|
|
@@ -4090,11 +4701,11 @@ var useClickOutside = ({
|
|
|
4090
4701
|
return ref;
|
|
4091
4702
|
};
|
|
4092
4703
|
|
|
4093
|
-
// src/hooks/use-debounce.ts
|
|
4094
|
-
var
|
|
4704
|
+
// src/hooks/utils/use-debounce.ts
|
|
4705
|
+
var import_react10 = require("react");
|
|
4095
4706
|
function useDebounce(value, delay) {
|
|
4096
|
-
const [debouncedValue, setDebouncedValue] = (0,
|
|
4097
|
-
(0,
|
|
4707
|
+
const [debouncedValue, setDebouncedValue] = (0, import_react10.useState)(value);
|
|
4708
|
+
(0, import_react10.useEffect)(() => {
|
|
4098
4709
|
const handler = setTimeout(() => {
|
|
4099
4710
|
setDebouncedValue(value);
|
|
4100
4711
|
}, delay);
|
|
@@ -4212,19 +4823,19 @@ var CloseIcon = ({ className = "" }) => {
|
|
|
4212
4823
|
};
|
|
4213
4824
|
|
|
4214
4825
|
// src/widget/basic/status-dropdown-field/controller.ts
|
|
4215
|
-
var
|
|
4216
|
-
var
|
|
4826
|
+
var import_react11 = require("react");
|
|
4827
|
+
var import_interface_logic9 = require("@fctc/interface-logic");
|
|
4217
4828
|
var statusDropdownController = (props) => {
|
|
4218
4829
|
const { selection, isForm, id, model, name, state, onRefetch } = props;
|
|
4219
|
-
const env = (0,
|
|
4830
|
+
const env = (0, import_interface_logic9.getEnv)();
|
|
4220
4831
|
const colors = {
|
|
4221
4832
|
normal: "bg-[#e9ecef]",
|
|
4222
4833
|
done: "bg-primary",
|
|
4223
4834
|
blocked: "bg-red-500"
|
|
4224
4835
|
};
|
|
4225
|
-
const [isOpen, setIsOpen] = (0,
|
|
4226
|
-
const buttonRef = (0,
|
|
4227
|
-
(0,
|
|
4836
|
+
const [isOpen, setIsOpen] = (0, import_react11.useState)(false);
|
|
4837
|
+
const buttonRef = (0, import_react11.useRef)(null);
|
|
4838
|
+
(0, import_react11.useEffect)(() => {
|
|
4228
4839
|
const handleClickOutside = (event) => {
|
|
4229
4840
|
if (buttonRef.current && !buttonRef.current.contains(event.target)) {
|
|
4230
4841
|
setIsOpen(false);
|
|
@@ -4235,7 +4846,7 @@ var statusDropdownController = (props) => {
|
|
|
4235
4846
|
document.removeEventListener("mousedown", handleClickOutside);
|
|
4236
4847
|
};
|
|
4237
4848
|
}, []);
|
|
4238
|
-
const { mutate: onSave } = (0,
|
|
4849
|
+
const { mutate: onSave } = (0, import_interface_logic9.useSave)();
|
|
4239
4850
|
const handleClick = async (status) => {
|
|
4240
4851
|
setIsOpen(!isOpen);
|
|
4241
4852
|
onSave(
|
|
@@ -4265,8 +4876,8 @@ var statusDropdownController = (props) => {
|
|
|
4265
4876
|
};
|
|
4266
4877
|
|
|
4267
4878
|
// src/widget/basic/many2one-field/controller.ts
|
|
4268
|
-
var
|
|
4269
|
-
var
|
|
4879
|
+
var import_react12 = require("react");
|
|
4880
|
+
var import_interface_logic10 = require("@fctc/interface-logic");
|
|
4270
4881
|
var many2oneFieldController = (props) => {
|
|
4271
4882
|
const {
|
|
4272
4883
|
name,
|
|
@@ -4281,24 +4892,24 @@ var many2oneFieldController = (props) => {
|
|
|
4281
4892
|
showDetail = true,
|
|
4282
4893
|
actionData
|
|
4283
4894
|
} = props;
|
|
4284
|
-
const [options, setOptions] = (0,
|
|
4285
|
-
const [isShowModalMany2Many, setIsShowModalMany2Many] = (0,
|
|
4286
|
-
const [tempSelectedOption, setTempSelectedOption] = (0,
|
|
4287
|
-
const { menuList } = (0,
|
|
4288
|
-
const { context } = (0,
|
|
4289
|
-
const [domainModal, setDomainModal] = (0,
|
|
4895
|
+
const [options, setOptions] = (0, import_react12.useState)([]);
|
|
4896
|
+
const [isShowModalMany2Many, setIsShowModalMany2Many] = (0, import_react12.useState)(false);
|
|
4897
|
+
const [tempSelectedOption, setTempSelectedOption] = (0, import_react12.useState)(null);
|
|
4898
|
+
const { menuList } = (0, import_interface_logic10.useAppSelector)(import_interface_logic10.selectNavbar);
|
|
4899
|
+
const { context } = (0, import_interface_logic10.useAppSelector)(import_interface_logic10.selectEnv);
|
|
4900
|
+
const [domainModal, setDomainModal] = (0, import_react12.useState)(null);
|
|
4290
4901
|
const initValue = methods?.getValues(name);
|
|
4291
|
-
const domainObject = (0,
|
|
4292
|
-
() => (0,
|
|
4902
|
+
const domainObject = (0, import_react12.useMemo)(
|
|
4903
|
+
() => (0, import_interface_logic10.evalJSONDomain)(domain, JSON.parse(JSON.stringify(formValues)) ?? {}),
|
|
4293
4904
|
[domain, formValues]
|
|
4294
4905
|
);
|
|
4295
|
-
const optionsObject = (0,
|
|
4906
|
+
const optionsObject = (0, import_interface_logic10.evalJSONContext)(fieldOptions) || {};
|
|
4296
4907
|
const contextObject = {
|
|
4297
|
-
...(0,
|
|
4908
|
+
...(0, import_interface_logic10.evalJSONContext)(actionData?.context) || {},
|
|
4298
4909
|
...fieldContext,
|
|
4299
4910
|
...context
|
|
4300
4911
|
};
|
|
4301
|
-
const actionId = (0,
|
|
4912
|
+
const actionId = (0, import_react12.useMemo)(
|
|
4302
4913
|
() => menuList?.flatMap(
|
|
4303
4914
|
(item) => item?.child_id.filter(
|
|
4304
4915
|
(childItem) => childItem?.is_display && childItem?.action?.res_model === relation
|
|
@@ -4321,23 +4932,23 @@ var many2oneFieldController = (props) => {
|
|
|
4321
4932
|
data: dataOfSelection,
|
|
4322
4933
|
refetch,
|
|
4323
4934
|
isFetching
|
|
4324
|
-
} = (0,
|
|
4935
|
+
} = (0, import_interface_logic10.useGetSelection)({
|
|
4325
4936
|
data,
|
|
4326
4937
|
queryKey,
|
|
4327
4938
|
enabled: false
|
|
4328
4939
|
});
|
|
4329
|
-
const selectOptions = (0,
|
|
4940
|
+
const selectOptions = (0, import_react12.useMemo)(() => {
|
|
4330
4941
|
return dataOfSelection?.records?.map((val) => ({
|
|
4331
4942
|
value: val?.id,
|
|
4332
4943
|
label: val?.display_name || val?.name
|
|
4333
4944
|
})) || [];
|
|
4334
4945
|
}, [dataOfSelection]);
|
|
4335
|
-
(0,
|
|
4946
|
+
(0, import_react12.useEffect)(() => {
|
|
4336
4947
|
setOptions(selectOptions);
|
|
4337
4948
|
setDomainModal(domainObject);
|
|
4338
|
-
if (relation === "student.subject") (0,
|
|
4949
|
+
if (relation === "student.subject") (0, import_interface_logic10.setListSubject)(selectOptions);
|
|
4339
4950
|
}, [selectOptions]);
|
|
4340
|
-
(0,
|
|
4951
|
+
(0, import_react12.useEffect)(() => {
|
|
4341
4952
|
if (!propValue && tempSelectedOption) {
|
|
4342
4953
|
methods.setValue(name, null);
|
|
4343
4954
|
setTempSelectedOption(null);
|
|
@@ -4348,15 +4959,15 @@ var many2oneFieldController = (props) => {
|
|
|
4348
4959
|
});
|
|
4349
4960
|
}
|
|
4350
4961
|
}, [propValue]);
|
|
4351
|
-
const fetchMoreOptions = (0,
|
|
4962
|
+
const fetchMoreOptions = (0, import_react12.useCallback)(() => {
|
|
4352
4963
|
refetch();
|
|
4353
4964
|
}, [refetch]);
|
|
4354
|
-
(0,
|
|
4965
|
+
(0, import_react12.useEffect)(() => {
|
|
4355
4966
|
if (actionId) {
|
|
4356
4967
|
localStorage.setItem("aid", actionId);
|
|
4357
4968
|
}
|
|
4358
4969
|
}, [actionId]);
|
|
4359
|
-
const handleChooseRecord = (0,
|
|
4970
|
+
const handleChooseRecord = (0, import_react12.useCallback)(
|
|
4360
4971
|
(idRecord) => {
|
|
4361
4972
|
const newOption = options.find(
|
|
4362
4973
|
(option) => option.value === idRecord
|
|
@@ -4381,8 +4992,8 @@ var many2oneFieldController = (props) => {
|
|
|
4381
4992
|
},
|
|
4382
4993
|
[options, methods, name, onChange]
|
|
4383
4994
|
);
|
|
4384
|
-
const handleClose = (0,
|
|
4385
|
-
const handleSelectChange = (0,
|
|
4995
|
+
const handleClose = (0, import_react12.useCallback)(() => setIsShowModalMany2Many(false), []);
|
|
4996
|
+
const handleSelectChange = (0, import_react12.useCallback)(
|
|
4386
4997
|
(selectedOption) => {
|
|
4387
4998
|
if (!selectedOption) {
|
|
4388
4999
|
methods.setValue(name, null, { shouldDirty: true });
|
|
@@ -4432,21 +5043,18 @@ var many2oneFieldController = (props) => {
|
|
|
4432
5043
|
};
|
|
4433
5044
|
|
|
4434
5045
|
// src/widget/basic/many2one-button-field/controller.ts
|
|
4435
|
-
var
|
|
4436
|
-
var many2oneButtonController = ({
|
|
4437
|
-
relation
|
|
4438
|
-
methods,
|
|
4439
|
-
domain
|
|
4440
|
-
}) => {
|
|
5046
|
+
var import_interface_logic11 = require("@fctc/interface-logic");
|
|
5047
|
+
var many2oneButtonController = (props) => {
|
|
5048
|
+
const { domain, methods, relation } = props;
|
|
4441
5049
|
const actionDataString = sessionStorage.getItem("actionData");
|
|
4442
|
-
const env = (0,
|
|
4443
|
-
const domainObject = (0,
|
|
5050
|
+
const env = (0, import_interface_logic11.getEnv)();
|
|
5051
|
+
const domainObject = (0, import_interface_logic11.evalJSONDomain)(domain, methods?.getValues() || {});
|
|
4444
5052
|
const actionData = actionDataString && actionDataString !== "undefined" ? JSON.parse(actionDataString) : {};
|
|
4445
|
-
const { data: dataOfSelection } = (0,
|
|
5053
|
+
const { data: dataOfSelection } = (0, import_interface_logic11.useGetSelection)({
|
|
4446
5054
|
data: {
|
|
4447
5055
|
model: relation ?? "",
|
|
4448
5056
|
domain: domainObject,
|
|
4449
|
-
context: { ...env.context, ...(0,
|
|
5057
|
+
context: { ...env.context, ...(0, import_interface_logic11.evalJSONContext)(actionData?.context) }
|
|
4450
5058
|
},
|
|
4451
5059
|
queryKey: [`data_${relation}`, domainObject]
|
|
4452
5060
|
});
|
|
@@ -4460,26 +5068,15 @@ var many2oneButtonController = ({
|
|
|
4460
5068
|
};
|
|
4461
5069
|
|
|
4462
5070
|
// src/widget/basic/many2many-field/controller.ts
|
|
4463
|
-
var
|
|
4464
|
-
var
|
|
5071
|
+
var import_react14 = require("react");
|
|
5072
|
+
var import_interface_logic13 = require("@fctc/interface-logic");
|
|
4465
5073
|
|
|
4466
|
-
// src/widget/table/
|
|
4467
|
-
var
|
|
4468
|
-
var
|
|
4469
|
-
|
|
4470
|
-
const
|
|
4471
|
-
const
|
|
4472
|
-
if (buttons?.length) {
|
|
4473
|
-
others.push({
|
|
4474
|
-
type_co: "buttons",
|
|
4475
|
-
buttons
|
|
4476
|
-
});
|
|
4477
|
-
}
|
|
4478
|
-
return others;
|
|
4479
|
-
}
|
|
4480
|
-
var useTableHandler = ({ data }) => {
|
|
4481
|
-
const [rows, setRows] = (0, import_react5.useState)(data.records || []);
|
|
4482
|
-
const [columns, setColumns] = (0, import_react5.useState)([]);
|
|
5074
|
+
// src/widget/advance/table/table-view/controller.ts
|
|
5075
|
+
var import_interface_logic12 = require("@fctc/interface-logic");
|
|
5076
|
+
var import_react13 = require("react");
|
|
5077
|
+
var tableController = ({ data }) => {
|
|
5078
|
+
const [rows, setRows] = (0, import_react13.useState)(data.records || []);
|
|
5079
|
+
const [columns, setColumns] = (0, import_react13.useState)([]);
|
|
4483
5080
|
const dataModelFields = data.fields?.map((field) => {
|
|
4484
5081
|
return {
|
|
4485
5082
|
...data.dataModel?.[field?.name],
|
|
@@ -4507,14 +5104,14 @@ var useTableHandler = ({ data }) => {
|
|
|
4507
5104
|
return item.display_name ? { ...transformedItem, item: item.display_name } : transformedItem;
|
|
4508
5105
|
});
|
|
4509
5106
|
};
|
|
4510
|
-
(0,
|
|
5107
|
+
(0, import_react13.useEffect)(() => {
|
|
4511
5108
|
setRows(transformData(data.records || null));
|
|
4512
5109
|
}, [data.records]);
|
|
4513
5110
|
const handleGetColumns = () => {
|
|
4514
5111
|
let cols = [];
|
|
4515
5112
|
try {
|
|
4516
5113
|
cols = mergeFields?.filter((item) => {
|
|
4517
|
-
return item?.widget !== "details_Receive_money" && !(item?.column_invisible ?
|
|
5114
|
+
return item?.widget !== "details_Receive_money" && !(item?.column_invisible ? import_interface_logic12.domainHelper.matchDomains(data.context, item?.column_invisible) : item?.invisible ? import_interface_logic12.domainHelper.matchDomains(data.context, item?.invisible) : false);
|
|
4518
5115
|
})?.map((field) => {
|
|
4519
5116
|
return {
|
|
4520
5117
|
name: field?.name,
|
|
@@ -4528,7 +5125,7 @@ var useTableHandler = ({ data }) => {
|
|
|
4528
5125
|
}
|
|
4529
5126
|
return cols;
|
|
4530
5127
|
};
|
|
4531
|
-
(0,
|
|
5128
|
+
(0, import_react13.useEffect)(() => {
|
|
4532
5129
|
const columns2 = handleGetColumns();
|
|
4533
5130
|
setColumns(columns2);
|
|
4534
5131
|
}, [data.records]);
|
|
@@ -4569,17 +5166,14 @@ var many2manyFieldController = (props) => {
|
|
|
4569
5166
|
options,
|
|
4570
5167
|
sessionStorageUtils
|
|
4571
5168
|
} = props;
|
|
4572
|
-
const appDispatch = (0,
|
|
5169
|
+
const appDispatch = (0, import_interface_logic13.useAppDispatch)();
|
|
4573
5170
|
const actionData = sessionStorageUtils.getActionData();
|
|
4574
5171
|
const [debouncedPage] = useDebounce(page, 500);
|
|
4575
|
-
const [order, setOrder] = (0,
|
|
4576
|
-
const [isLoadedData, setIsLoadedData] = (0,
|
|
4577
|
-
const [domainMany2Many, setDomainMany2Many] = (0,
|
|
4578
|
-
const env = (0,
|
|
4579
|
-
const {
|
|
4580
|
-
// tableHead,
|
|
4581
|
-
selectedTags
|
|
4582
|
-
} = (0, import_interface_logic5.useAppSelector)(import_interface_logic5.selectSearch);
|
|
5172
|
+
const [order, setOrder] = (0, import_react14.useState)();
|
|
5173
|
+
const [isLoadedData, setIsLoadedData] = (0, import_react14.useState)(false);
|
|
5174
|
+
const [domainMany2Many, setDomainMany2Many] = (0, import_react14.useState)(domain);
|
|
5175
|
+
const env = (0, import_interface_logic13.getEnv)();
|
|
5176
|
+
const { selectedTags } = (0, import_interface_logic13.useAppSelector)(import_interface_logic13.selectSearch);
|
|
4583
5177
|
const viewParams = {
|
|
4584
5178
|
model: relation,
|
|
4585
5179
|
views: [
|
|
@@ -4588,11 +5182,11 @@ var many2manyFieldController = (props) => {
|
|
|
4588
5182
|
],
|
|
4589
5183
|
context
|
|
4590
5184
|
};
|
|
4591
|
-
const { data: viewResponse, isFetched: isViewReponseFetched } = (0,
|
|
5185
|
+
const { data: viewResponse, isFetched: isViewReponseFetched } = (0, import_interface_logic13.useGetView)(
|
|
4592
5186
|
viewParams,
|
|
4593
5187
|
actionData
|
|
4594
5188
|
);
|
|
4595
|
-
const baseModel = (0,
|
|
5189
|
+
const baseModel = (0, import_react14.useMemo)(
|
|
4596
5190
|
() => ({
|
|
4597
5191
|
name: String(relation),
|
|
4598
5192
|
view: viewResponse || {},
|
|
@@ -4604,26 +5198,26 @@ var many2manyFieldController = (props) => {
|
|
|
4604
5198
|
}),
|
|
4605
5199
|
[model, viewResponse]
|
|
4606
5200
|
);
|
|
4607
|
-
const initModel = (0,
|
|
4608
|
-
const modelInstance = (0,
|
|
5201
|
+
const initModel = (0, import_interface_logic13.useModel)();
|
|
5202
|
+
const modelInstance = (0, import_react14.useMemo)(() => {
|
|
4609
5203
|
if (viewResponse) {
|
|
4610
5204
|
return initModel.initModel(baseModel);
|
|
4611
5205
|
}
|
|
4612
5206
|
return null;
|
|
4613
5207
|
}, [baseModel, viewResponse]);
|
|
4614
|
-
const specification = (0,
|
|
5208
|
+
const specification = (0, import_react14.useMemo)(() => {
|
|
4615
5209
|
if (modelInstance) {
|
|
4616
5210
|
return modelInstance.getSpecification();
|
|
4617
5211
|
}
|
|
4618
5212
|
return null;
|
|
4619
5213
|
}, [modelInstance]);
|
|
4620
5214
|
const default_order = viewResponse && viewResponse?.views?.list?.default_order;
|
|
4621
|
-
const optionsObject = tab?.options ? (0,
|
|
5215
|
+
const optionsObject = tab?.options ? (0, import_interface_logic13.evalJSONContext)(tab?.options) : (options ? (0, import_interface_logic13.evalJSONContext)(options) : {}) || {};
|
|
4622
5216
|
const fetchData = async () => {
|
|
4623
5217
|
try {
|
|
4624
5218
|
setDomainMany2Many(domain);
|
|
4625
|
-
appDispatch((0,
|
|
4626
|
-
appDispatch((0,
|
|
5219
|
+
appDispatch((0, import_interface_logic13.setFirstDomain)(domain));
|
|
5220
|
+
appDispatch((0, import_interface_logic13.setViewDataStore)(viewResponse));
|
|
4627
5221
|
const modalData = viewResponse?.views?.list?.fields.map((field) => ({
|
|
4628
5222
|
...viewResponse?.models?.[String(model)]?.[field?.name],
|
|
4629
5223
|
...field
|
|
@@ -4634,7 +5228,7 @@ var many2manyFieldController = (props) => {
|
|
|
4634
5228
|
[`${aid}_${relation}_popupmany2many`]: modalData
|
|
4635
5229
|
});
|
|
4636
5230
|
}
|
|
4637
|
-
appDispatch((0,
|
|
5231
|
+
appDispatch((0, import_interface_logic13.setPage)(0));
|
|
4638
5232
|
} catch (err) {
|
|
4639
5233
|
console.log(err);
|
|
4640
5234
|
}
|
|
@@ -4656,7 +5250,7 @@ var many2manyFieldController = (props) => {
|
|
|
4656
5250
|
context,
|
|
4657
5251
|
fields: groupByDomain?.fields,
|
|
4658
5252
|
groupby: [groupByDomain?.contexts[0]?.group_by],
|
|
4659
|
-
sort: order ? order : default_order ? (0,
|
|
5253
|
+
sort: order ? order : default_order ? (0, import_interface_logic13.formatSortingString)(default_order) : ""
|
|
4660
5254
|
};
|
|
4661
5255
|
const enabled = isLoadedData && !!specification && !!relation && !!domainMany2Many && !!viewResponse;
|
|
4662
5256
|
const {
|
|
@@ -4664,24 +5258,24 @@ var many2manyFieldController = (props) => {
|
|
|
4664
5258
|
isLoading: isDataLoading,
|
|
4665
5259
|
isFetched: isDataResponseFetched,
|
|
4666
5260
|
isPlaceholderData
|
|
4667
|
-
} = (0,
|
|
4668
|
-
(0,
|
|
5261
|
+
} = (0, import_interface_logic13.useGetListData)(data, queryKey, enabled);
|
|
5262
|
+
(0, import_react14.useEffect)(() => {
|
|
4669
5263
|
if (viewResponse) {
|
|
4670
5264
|
fetchData();
|
|
4671
5265
|
}
|
|
4672
5266
|
return () => {
|
|
4673
|
-
appDispatch((0,
|
|
5267
|
+
appDispatch((0, import_interface_logic13.setGroupByDomain)(null));
|
|
4674
5268
|
setFields((prevFields) => ({
|
|
4675
5269
|
...prevFields,
|
|
4676
5270
|
[`${aid}_${relation}_popupmany2many`]: null
|
|
4677
5271
|
}));
|
|
4678
|
-
appDispatch((0,
|
|
5272
|
+
appDispatch((0, import_interface_logic13.setPage)(0));
|
|
4679
5273
|
setSelectedRowKeys([]);
|
|
4680
5274
|
setDomainMany2Many(null);
|
|
4681
5275
|
setIsLoadedData(false);
|
|
4682
5276
|
};
|
|
4683
5277
|
}, [viewResponse]);
|
|
4684
|
-
const { rows, columns, typeTable } =
|
|
5278
|
+
const { rows, columns, typeTable } = tableController({
|
|
4685
5279
|
data: {
|
|
4686
5280
|
fields: fields?.[`${aid}_${relation}_popupmany2many`] || viewResponse?.views?.list?.fields,
|
|
4687
5281
|
records: dataResponse?.records ?? dataResponse?.groups,
|
|
@@ -4699,18 +5293,18 @@ var many2manyFieldController = (props) => {
|
|
|
4699
5293
|
refetch,
|
|
4700
5294
|
data: dataFormViewResponse,
|
|
4701
5295
|
isSuccess
|
|
4702
|
-
} = (0,
|
|
5296
|
+
} = (0, import_interface_logic13.useGetFormView)({
|
|
4703
5297
|
data: dataFormView,
|
|
4704
5298
|
queryKey: [`form-view-action-${relation}`],
|
|
4705
5299
|
enabled: false
|
|
4706
5300
|
});
|
|
4707
|
-
(0,
|
|
5301
|
+
(0, import_react14.useEffect)(() => {
|
|
4708
5302
|
if (isSuccess && dataFormViewResponse) {
|
|
4709
5303
|
sessionStorage.setItem("actionData", JSON.stringify(dataFormViewResponse));
|
|
4710
5304
|
window.location.href = `/form/menu?model=${relation}`;
|
|
4711
5305
|
}
|
|
4712
5306
|
}, [isSuccess]);
|
|
4713
|
-
(0,
|
|
5307
|
+
(0, import_react14.useEffect)(() => {
|
|
4714
5308
|
if (domainMany2Many && !isLoadedData) {
|
|
4715
5309
|
setIsLoadedData(true);
|
|
4716
5310
|
}
|
|
@@ -4722,42 +5316,12 @@ var many2manyFieldController = (props) => {
|
|
|
4722
5316
|
console.log(error);
|
|
4723
5317
|
}
|
|
4724
5318
|
};
|
|
4725
|
-
return {
|
|
4726
|
-
rows,
|
|
4727
|
-
columns,
|
|
4728
|
-
typeTable,
|
|
4729
|
-
handleCreateNewOnPage,
|
|
4730
|
-
isLoadedData,
|
|
4731
|
-
domainMany2Many,
|
|
4732
|
-
isDataLoading,
|
|
4733
|
-
isDataResponseFetched,
|
|
4734
|
-
isPlaceholderData,
|
|
4735
|
-
queryKey,
|
|
4736
|
-
data,
|
|
4737
|
-
specification,
|
|
4738
|
-
enabled,
|
|
4739
|
-
isViewReponseFetched,
|
|
4740
|
-
actionData,
|
|
4741
|
-
viewResponse,
|
|
4742
|
-
debouncedPage,
|
|
4743
|
-
order,
|
|
4744
|
-
default_order,
|
|
4745
|
-
optionsObject,
|
|
4746
|
-
setDomainMany2Many,
|
|
4747
|
-
// tableHead,
|
|
4748
|
-
selectedTags,
|
|
4749
|
-
initModel,
|
|
4750
|
-
modelInstance,
|
|
4751
|
-
baseModel,
|
|
4752
|
-
dataResponse,
|
|
4753
|
-
isLoading: isDataLoading,
|
|
4754
|
-
setOrder
|
|
4755
|
-
};
|
|
5319
|
+
return {};
|
|
4756
5320
|
};
|
|
4757
5321
|
|
|
4758
5322
|
// src/widget/basic/many2many-tags-field/controller.ts
|
|
4759
|
-
var
|
|
4760
|
-
var
|
|
5323
|
+
var import_react15 = require("react");
|
|
5324
|
+
var import_interface_logic14 = require("@fctc/interface-logic");
|
|
4761
5325
|
var many2manyTagsController = (props) => {
|
|
4762
5326
|
const {
|
|
4763
5327
|
relation,
|
|
@@ -4768,10 +5332,10 @@ var many2manyTagsController = (props) => {
|
|
|
4768
5332
|
placeholderNoOption
|
|
4769
5333
|
} = props;
|
|
4770
5334
|
const isUser = relation === "res.users" || relation === "res.partner";
|
|
4771
|
-
const env = (0,
|
|
4772
|
-
const addtionalFields = optionsFields ? (0,
|
|
4773
|
-
const domainObject = (0,
|
|
4774
|
-
() => (0,
|
|
5335
|
+
const env = (0, import_interface_logic14.getEnv)();
|
|
5336
|
+
const addtionalFields = optionsFields ? (0, import_interface_logic14.evalJSONContext)(optionsFields) : null;
|
|
5337
|
+
const domainObject = (0, import_react15.useMemo)(
|
|
5338
|
+
() => (0, import_interface_logic14.evalJSONDomain)(domain, JSON.parse(JSON.stringify(formValues || {}))),
|
|
4775
5339
|
[domain, formValues]
|
|
4776
5340
|
);
|
|
4777
5341
|
const data = {
|
|
@@ -4781,13 +5345,13 @@ var many2manyTagsController = (props) => {
|
|
|
4781
5345
|
id: {},
|
|
4782
5346
|
name: {},
|
|
4783
5347
|
display_name: {},
|
|
4784
|
-
...widget &&
|
|
4785
|
-
...widget &&
|
|
5348
|
+
...widget && import_interface_logic14.WIDGETAVATAR[widget] ? { image_256: {} } : {},
|
|
5349
|
+
...widget && import_interface_logic14.WIDGETCOLOR[widget] && addtionalFields?.color_field ? { color: {} } : {}
|
|
4786
5350
|
},
|
|
4787
5351
|
enabled: true,
|
|
4788
5352
|
context: env.context
|
|
4789
5353
|
};
|
|
4790
|
-
const { data: dataOfSelection } = (0,
|
|
5354
|
+
const { data: dataOfSelection } = (0, import_interface_logic14.useGetSelection)({
|
|
4791
5355
|
data,
|
|
4792
5356
|
queryKey: [`data_${relation}`, domainObject]
|
|
4793
5357
|
});
|
|
@@ -4813,8 +5377,8 @@ var many2manyTagsController = (props) => {
|
|
|
4813
5377
|
};
|
|
4814
5378
|
|
|
4815
5379
|
// src/widget/basic/status-bar-field/controller.ts
|
|
4816
|
-
var
|
|
4817
|
-
var
|
|
5380
|
+
var import_react16 = require("react");
|
|
5381
|
+
var import_interface_logic15 = require("@fctc/interface-logic");
|
|
4818
5382
|
var durationController = (props) => {
|
|
4819
5383
|
const {
|
|
4820
5384
|
relation,
|
|
@@ -4831,14 +5395,14 @@ var durationController = (props) => {
|
|
|
4831
5395
|
name: "",
|
|
4832
5396
|
fold: ""
|
|
4833
5397
|
};
|
|
4834
|
-
const [disabled, setDisabled] = (0,
|
|
4835
|
-
const [modelStatus, setModalStatus] = (0,
|
|
4836
|
-
const { context } = (0,
|
|
5398
|
+
const [disabled, setDisabled] = (0, import_react16.useState)(false);
|
|
5399
|
+
const [modelStatus, setModalStatus] = (0, import_react16.useState)(false);
|
|
5400
|
+
const { context } = (0, import_interface_logic15.useAppSelector)(import_interface_logic15.selectEnv);
|
|
4837
5401
|
const queryKey = [`data-status-duration`, specification];
|
|
4838
5402
|
const listDataProps = {
|
|
4839
5403
|
model: relation,
|
|
4840
5404
|
specification,
|
|
4841
|
-
domain: (0,
|
|
5405
|
+
domain: (0, import_interface_logic15.evalJSONDomain)(domain, JSON.parse(JSON.stringify(formValues))),
|
|
4842
5406
|
limit: 10,
|
|
4843
5407
|
offset: 0,
|
|
4844
5408
|
fields: "",
|
|
@@ -4848,8 +5412,8 @@ var durationController = (props) => {
|
|
|
4848
5412
|
},
|
|
4849
5413
|
sort: ""
|
|
4850
5414
|
};
|
|
4851
|
-
const { data: dataResponse } = (0,
|
|
4852
|
-
const { mutate: fetchChangeStatus } = (0,
|
|
5415
|
+
const { data: dataResponse } = (0, import_interface_logic15.useGetListData)(listDataProps, queryKey);
|
|
5416
|
+
const { mutate: fetchChangeStatus } = (0, import_interface_logic15.useChangeStatus)();
|
|
4853
5417
|
const handleClick = async (stage_id) => {
|
|
4854
5418
|
setDisabled(true);
|
|
4855
5419
|
if (stage_id) {
|
|
@@ -4885,26 +5449,26 @@ var durationController = (props) => {
|
|
|
4885
5449
|
};
|
|
4886
5450
|
|
|
4887
5451
|
// src/widget/basic/priority-field/controller.ts
|
|
4888
|
-
var
|
|
5452
|
+
var import_interface_logic16 = require("@fctc/interface-logic");
|
|
4889
5453
|
var priorityFieldController = (props) => {
|
|
4890
5454
|
const {
|
|
4891
5455
|
value,
|
|
4892
|
-
selection,
|
|
4893
5456
|
isForm,
|
|
4894
5457
|
name,
|
|
4895
5458
|
methods,
|
|
4896
|
-
id,
|
|
4897
5459
|
onChange,
|
|
4898
5460
|
model,
|
|
5461
|
+
selection,
|
|
5462
|
+
id,
|
|
4899
5463
|
actionData,
|
|
4900
5464
|
viewData,
|
|
4901
5465
|
context
|
|
4902
5466
|
} = props;
|
|
4903
|
-
const _context = { ...(0,
|
|
5467
|
+
const _context = { ...(0, import_interface_logic16.evalJSONContext)(actionData?.context) };
|
|
4904
5468
|
const contextObject = { ...context, ..._context };
|
|
4905
5469
|
const defaultPriority = parseInt(value) + 1;
|
|
4906
5470
|
const label = viewData?.models?.[model]?.[name ?? ""]?.string ?? name;
|
|
4907
|
-
const { mutateAsync: fetchSave } = (0,
|
|
5471
|
+
const { mutateAsync: fetchSave } = (0, import_interface_logic16.useSave)();
|
|
4908
5472
|
const savePriorities = async ({
|
|
4909
5473
|
value: value2,
|
|
4910
5474
|
resetPriority
|
|
@@ -4939,8 +5503,8 @@ var priorityFieldController = (props) => {
|
|
|
4939
5503
|
};
|
|
4940
5504
|
|
|
4941
5505
|
// src/widget/basic/float-time-field/controller.ts
|
|
4942
|
-
var
|
|
4943
|
-
var
|
|
5506
|
+
var import_react17 = require("react");
|
|
5507
|
+
var import_interface_logic17 = require("@fctc/interface-logic");
|
|
4944
5508
|
var floatTimeFiledController = ({
|
|
4945
5509
|
onChange: fieldOnChange,
|
|
4946
5510
|
onBlur,
|
|
@@ -4949,11 +5513,11 @@ var floatTimeFiledController = ({
|
|
|
4949
5513
|
props
|
|
4950
5514
|
}) => {
|
|
4951
5515
|
const { name, defaultValue = 0, onChange } = props;
|
|
4952
|
-
const [input, setInput] = (0,
|
|
4953
|
-
(0,
|
|
5516
|
+
const [input, setInput] = (0, import_react17.useState)(
|
|
5517
|
+
(0, import_interface_logic17.convertFloatToTime)(value ?? defaultValue)
|
|
4954
5518
|
);
|
|
4955
|
-
const [formattedTime, setFormattedTime] = (0,
|
|
4956
|
-
const [errors, setErrors] = (0,
|
|
5519
|
+
const [formattedTime, setFormattedTime] = (0, import_react17.useState)("");
|
|
5520
|
+
const [errors, setErrors] = (0, import_react17.useState)("");
|
|
4957
5521
|
const handleInputChange = (e) => {
|
|
4958
5522
|
const raw = e.target.value.replace(/[^\d:]/g, "");
|
|
4959
5523
|
setInput(raw);
|
|
@@ -4983,7 +5547,7 @@ var floatTimeFiledController = ({
|
|
|
4983
5547
|
if (!isDirty) return;
|
|
4984
5548
|
if (formattedTime) {
|
|
4985
5549
|
setInput(formattedTime);
|
|
4986
|
-
const floatVal = (0,
|
|
5550
|
+
const floatVal = (0, import_interface_logic17.convertTimeToFloat)(formattedTime);
|
|
4987
5551
|
fieldOnChange(floatVal);
|
|
4988
5552
|
if (onChange) {
|
|
4989
5553
|
onChange(name ?? "", floatVal);
|
|
@@ -5026,7 +5590,31 @@ var floatTimeFiledController = ({
|
|
|
5026
5590
|
};
|
|
5027
5591
|
|
|
5028
5592
|
// src/widget/basic/float-field/controller.ts
|
|
5029
|
-
var
|
|
5593
|
+
var import_react18 = require("react");
|
|
5594
|
+
|
|
5595
|
+
// src/utils/i18n.ts
|
|
5596
|
+
var import_react_i18next2 = require("react-i18next");
|
|
5597
|
+
var import_i18next = __toESM(require("i18next"));
|
|
5598
|
+
var import_i18next_browser_languagedetector = __toESM(require("i18next-browser-languagedetector"));
|
|
5599
|
+
import_i18next.default.use(import_i18next_browser_languagedetector.default).use(import_react_i18next2.initReactI18next).init({
|
|
5600
|
+
resources: {
|
|
5601
|
+
vi: { translation: vi },
|
|
5602
|
+
en: { translation: en }
|
|
5603
|
+
},
|
|
5604
|
+
fallbackLng: "vi",
|
|
5605
|
+
lng: "vi_VN",
|
|
5606
|
+
debug: false,
|
|
5607
|
+
nonExplicitSupportedLngs: true,
|
|
5608
|
+
interpolation: {
|
|
5609
|
+
escapeValue: false
|
|
5610
|
+
},
|
|
5611
|
+
detection: {
|
|
5612
|
+
caches: ["cookie"]
|
|
5613
|
+
}
|
|
5614
|
+
});
|
|
5615
|
+
var i18n_default = import_i18next.default;
|
|
5616
|
+
|
|
5617
|
+
// src/widget/basic/float-field/controller.ts
|
|
5030
5618
|
var floatController = ({
|
|
5031
5619
|
onChange,
|
|
5032
5620
|
value,
|
|
@@ -5034,10 +5622,10 @@ var floatController = ({
|
|
|
5034
5622
|
}) => {
|
|
5035
5623
|
const { name, required, methods, onChange: handleOnchange, string } = props;
|
|
5036
5624
|
const { setError, clearErrors } = methods;
|
|
5037
|
-
const [inputValue, setInputValue] = (0,
|
|
5625
|
+
const [inputValue, setInputValue] = (0, import_react18.useState)(
|
|
5038
5626
|
value !== void 0 && value !== null ? useFormatFloatNumber(value) : ""
|
|
5039
5627
|
);
|
|
5040
|
-
(0,
|
|
5628
|
+
(0, import_react18.useEffect)(() => {
|
|
5041
5629
|
if (value !== void 0 && value !== null && value !== parseFloat(inputValue?.replace(/,/g, ""))) {
|
|
5042
5630
|
setInputValue(useFormatFloatNumber(value));
|
|
5043
5631
|
clearErrors(name);
|
|
@@ -5045,9 +5633,9 @@ var floatController = ({
|
|
|
5045
5633
|
setInputValue("");
|
|
5046
5634
|
}
|
|
5047
5635
|
}, [value, name, clearErrors]);
|
|
5048
|
-
const isDirtyRef = (0,
|
|
5049
|
-
const inputRef = (0,
|
|
5050
|
-
const lastCommittedValueRef = (0,
|
|
5636
|
+
const isDirtyRef = (0, import_react18.useRef)(false);
|
|
5637
|
+
const inputRef = (0, import_react18.useRef)(null);
|
|
5638
|
+
const lastCommittedValueRef = (0, import_react18.useRef)(null);
|
|
5051
5639
|
const handleInputChange = (e) => {
|
|
5052
5640
|
const newValue = e.target.value;
|
|
5053
5641
|
const valueWithoutCommas = newValue.replace(/,/g, "");
|
|
@@ -5065,8 +5653,8 @@ var floatController = ({
|
|
|
5065
5653
|
if (!isNaN(parsedValue)) {
|
|
5066
5654
|
if (parsedValue < 0) {
|
|
5067
5655
|
setError(name, {
|
|
5068
|
-
type: "validate"
|
|
5069
|
-
|
|
5656
|
+
type: "validate",
|
|
5657
|
+
message: i18n_default.t("invalid_number")
|
|
5070
5658
|
});
|
|
5071
5659
|
} else {
|
|
5072
5660
|
onChange(parsedValue);
|
|
@@ -5089,8 +5677,8 @@ var floatController = ({
|
|
|
5089
5677
|
if (rawValue === "" || rawValue === ".") {
|
|
5090
5678
|
if (required) {
|
|
5091
5679
|
setError(name, {
|
|
5092
|
-
type: "required"
|
|
5093
|
-
|
|
5680
|
+
type: "required",
|
|
5681
|
+
message: `${string} ${i18n_default.t("must_required")}`
|
|
5094
5682
|
});
|
|
5095
5683
|
}
|
|
5096
5684
|
onChange(null);
|
|
@@ -5099,8 +5687,8 @@ var floatController = ({
|
|
|
5099
5687
|
} else if (!isNaN(parsedValue)) {
|
|
5100
5688
|
if (parsedValue < 0) {
|
|
5101
5689
|
setError(name, {
|
|
5102
|
-
type: "validate"
|
|
5103
|
-
|
|
5690
|
+
type: "validate",
|
|
5691
|
+
message: i18n_default.t("invalid_number")
|
|
5104
5692
|
});
|
|
5105
5693
|
setInputValue("");
|
|
5106
5694
|
lastCommittedValueRef.current = null;
|
|
@@ -5120,8 +5708,8 @@ var floatController = ({
|
|
|
5120
5708
|
}
|
|
5121
5709
|
} else {
|
|
5122
5710
|
setError(name, {
|
|
5123
|
-
type: "validate"
|
|
5124
|
-
|
|
5711
|
+
type: "validate",
|
|
5712
|
+
message: i18n_default.t("invalid_number")
|
|
5125
5713
|
});
|
|
5126
5714
|
setInputValue("");
|
|
5127
5715
|
lastCommittedValueRef.current = null;
|
|
@@ -5148,10 +5736,10 @@ var useFormatFloatNumber = (value) => {
|
|
|
5148
5736
|
};
|
|
5149
5737
|
|
|
5150
5738
|
// src/widget/basic/download-file-field/controller.ts
|
|
5151
|
-
var
|
|
5739
|
+
var import_react19 = require("react");
|
|
5152
5740
|
var downloadFileController = () => {
|
|
5153
|
-
const inputId = (0,
|
|
5154
|
-
const [file, setFile] = (0,
|
|
5741
|
+
const inputId = (0, import_react19.useId)();
|
|
5742
|
+
const [file, setFile] = (0, import_react19.useState)(null);
|
|
5155
5743
|
const handleFileChange = (e) => {
|
|
5156
5744
|
setFile(e.target.files[0]);
|
|
5157
5745
|
};
|
|
@@ -5219,8 +5807,8 @@ var dateFieldController = (props) => {
|
|
|
5219
5807
|
widget,
|
|
5220
5808
|
min,
|
|
5221
5809
|
max,
|
|
5222
|
-
formValues,
|
|
5223
5810
|
viewData,
|
|
5811
|
+
formValues,
|
|
5224
5812
|
model
|
|
5225
5813
|
} = props;
|
|
5226
5814
|
const range = (start, end, step = 1) => {
|
|
@@ -5275,18 +5863,30 @@ var dateFieldController = (props) => {
|
|
|
5275
5863
|
const compareNow = showTime ? now : now.clone().startOf("day");
|
|
5276
5864
|
if (minNowValue) {
|
|
5277
5865
|
if (compareSelected.isBefore(compareNow) && typeof minNowValue === "boolean" && minNowValue === true) {
|
|
5866
|
+
return `${i18n_default.t("please_enter")} ${string} ${i18n_default.t(
|
|
5867
|
+
"greater_or_equal_now"
|
|
5868
|
+
)}`;
|
|
5278
5869
|
} else if (import_moment.default.isMoment(minNowValue)) {
|
|
5279
5870
|
const compareMin = showTime ? minNowValue : minNowValue.clone().startOf("day");
|
|
5280
5871
|
if (compareSelected.isBefore(compareMin)) {
|
|
5281
5872
|
const fieldRelationDate = viewData?.models?.[model]?.[min ?? ""];
|
|
5873
|
+
return `${i18n_default.t("please_enter")} ${string} ${i18n_default.t(
|
|
5874
|
+
"greater_or_equal"
|
|
5875
|
+
)} ${fieldRelationDate?.string}`;
|
|
5282
5876
|
}
|
|
5283
5877
|
}
|
|
5284
5878
|
} else if (maxNowValue) {
|
|
5285
5879
|
if (compareSelected.isAfter(compareNow) && typeof maxNowValue === "boolean" && maxNowValue === true) {
|
|
5880
|
+
return `${i18n_default.t("please_enter")} ${string} ${i18n_default.t(
|
|
5881
|
+
"less_or_equal_now"
|
|
5882
|
+
)}`;
|
|
5286
5883
|
} else if (import_moment.default.isMoment(maxNowValue)) {
|
|
5287
5884
|
const compareMax = showTime ? maxNowValue : maxNowValue.clone().startOf("day");
|
|
5288
5885
|
if (compareSelected.isAfter(compareMax)) {
|
|
5289
5886
|
const fieldRelationDate = viewData?.models?.[model]?.[max ?? ""];
|
|
5887
|
+
return `${i18n_default.t("please_enter")} ${string} ${i18n_default.t(
|
|
5888
|
+
"less_or_equal"
|
|
5889
|
+
)} ${fieldRelationDate?.string}`;
|
|
5290
5890
|
}
|
|
5291
5891
|
}
|
|
5292
5892
|
}
|
|
@@ -5309,13 +5909,13 @@ var dateFieldController = (props) => {
|
|
|
5309
5909
|
};
|
|
5310
5910
|
|
|
5311
5911
|
// src/widget/basic/copy-link-button/controller.ts
|
|
5312
|
-
var
|
|
5313
|
-
var
|
|
5912
|
+
var import_react20 = require("react");
|
|
5913
|
+
var import_interface_logic18 = require("@fctc/interface-logic");
|
|
5314
5914
|
var copyLinkButtonController = (props) => {
|
|
5315
5915
|
const { value, defaultValue } = props;
|
|
5316
|
-
const [isCopied, setIsCopied] = (0,
|
|
5916
|
+
const [isCopied, setIsCopied] = (0, import_react20.useState)(false);
|
|
5317
5917
|
const handleCopyToClipboard = async (value2) => {
|
|
5318
|
-
await (0,
|
|
5918
|
+
await (0, import_interface_logic18.copyTextToClipboard)(value2);
|
|
5319
5919
|
setIsCopied(true);
|
|
5320
5920
|
setTimeout(() => setIsCopied(false), 2e3);
|
|
5321
5921
|
};
|
|
@@ -5327,49 +5927,15 @@ var copyLinkButtonController = (props) => {
|
|
|
5327
5927
|
};
|
|
5328
5928
|
};
|
|
5329
5929
|
|
|
5330
|
-
// src/widget/basic/color-field/color-wrapper-controller.ts
|
|
5331
|
-
var import_react13 = require("react");
|
|
5332
|
-
var colorWrapperController = (props) => {
|
|
5333
|
-
const { savePickColor, defaultColor, colors } = props;
|
|
5334
|
-
const [selectedColor, setSelectedColor] = (0, import_react13.useState)(colors[defaultColor]);
|
|
5335
|
-
const [showFullColors, setIsShowFullColor] = (0, import_react13.useState)(false);
|
|
5336
|
-
(0, import_react13.useEffect)(() => {
|
|
5337
|
-
setSelectedColor(colors[defaultColor]);
|
|
5338
|
-
}, [defaultColor]);
|
|
5339
|
-
const handleShowFullColors = () => {
|
|
5340
|
-
setIsShowFullColor(!showFullColors);
|
|
5341
|
-
};
|
|
5342
|
-
const pickColorsRef = (0, import_react13.useRef)(null);
|
|
5343
|
-
(0, import_react13.useEffect)(() => {
|
|
5344
|
-
const handleClickOutside = (event) => {
|
|
5345
|
-
if (pickColorsRef.current && !pickColorsRef.current.contains(event.target)) {
|
|
5346
|
-
setIsShowFullColor(false);
|
|
5347
|
-
}
|
|
5348
|
-
};
|
|
5349
|
-
document.addEventListener("mousedown", handleClickOutside);
|
|
5350
|
-
return () => {
|
|
5351
|
-
document.removeEventListener("mousedown", handleClickOutside);
|
|
5352
|
-
};
|
|
5353
|
-
}, []);
|
|
5354
|
-
return {
|
|
5355
|
-
selectedColor,
|
|
5356
|
-
showFullColors,
|
|
5357
|
-
setSelectedColor,
|
|
5358
|
-
handleShowFullColors,
|
|
5359
|
-
pickColorsRef,
|
|
5360
|
-
savePickColor
|
|
5361
|
-
};
|
|
5362
|
-
};
|
|
5363
|
-
|
|
5364
5930
|
// src/widget/basic/color-field/color-controller.ts
|
|
5365
|
-
var
|
|
5931
|
+
var import_interface_logic19 = require("@fctc/interface-logic");
|
|
5366
5932
|
var colorFieldController = (props) => {
|
|
5367
5933
|
const { value, isForm, name, formValues, idForm, model, actionData } = props;
|
|
5368
|
-
const env = (0,
|
|
5369
|
-
const _context = { ...(0,
|
|
5934
|
+
const env = (0, import_interface_logic19.getEnv)();
|
|
5935
|
+
const _context = { ...(0, import_interface_logic19.evalJSONContext)(actionData?.context) || {} };
|
|
5370
5936
|
const contextObject = { ...env.context, ..._context };
|
|
5371
5937
|
const idDefault = isForm ? idForm : formValues?.id;
|
|
5372
|
-
const { mutate: onSave } = (0,
|
|
5938
|
+
const { mutate: onSave } = (0, import_interface_logic19.useSave)();
|
|
5373
5939
|
const savePickColor = async (colorObject) => {
|
|
5374
5940
|
const { id } = colorObject;
|
|
5375
5941
|
if (value === id) return;
|
|
@@ -5394,16 +5960,16 @@ var colorFieldController = (props) => {
|
|
|
5394
5960
|
};
|
|
5395
5961
|
|
|
5396
5962
|
// src/widget/basic/binary-field/controller.ts
|
|
5397
|
-
var
|
|
5398
|
-
var
|
|
5963
|
+
var import_react21 = require("react");
|
|
5964
|
+
var import_interface_logic20 = require("@fctc/interface-logic");
|
|
5399
5965
|
var binaryFieldController = (props) => {
|
|
5400
5966
|
const { name, methods, readonly = false, value } = props;
|
|
5401
|
-
const inputId = (0,
|
|
5402
|
-
const [selectedImage, setSelectedImage] = (0,
|
|
5403
|
-
const [initialImage, setInitialImage] = (0,
|
|
5404
|
-
const [isInsideTable, setIsInsideTable] = (0,
|
|
5967
|
+
const inputId = (0, import_react21.useId)();
|
|
5968
|
+
const [selectedImage, setSelectedImage] = (0, import_react21.useState)(null);
|
|
5969
|
+
const [initialImage, setInitialImage] = (0, import_react21.useState)(value || null);
|
|
5970
|
+
const [isInsideTable, setIsInsideTable] = (0, import_react21.useState)(false);
|
|
5405
5971
|
const { setValue } = methods;
|
|
5406
|
-
const binaryRef = (0,
|
|
5972
|
+
const binaryRef = (0, import_react21.useRef)(null);
|
|
5407
5973
|
const convertUrlToBase64 = async (url) => {
|
|
5408
5974
|
try {
|
|
5409
5975
|
const response = await fetch(url);
|
|
@@ -5452,11 +6018,11 @@ var binaryFieldController = (props) => {
|
|
|
5452
6018
|
};
|
|
5453
6019
|
const checkIsImageLink = (url) => {
|
|
5454
6020
|
const imageExtensions = /\.(jpg|jpeg|png|gif|bmp|webp|svg|tiff|ico)$/i;
|
|
5455
|
-
return imageExtensions.test(url) || (0,
|
|
6021
|
+
return imageExtensions.test(url) || (0, import_interface_logic20.isBase64Image)(url) || isBlobUrl(url);
|
|
5456
6022
|
};
|
|
5457
6023
|
const getImageBase64WithMimeType = (base64) => {
|
|
5458
6024
|
if (typeof base64 !== "string" || base64.length < 10) return null;
|
|
5459
|
-
if ((0,
|
|
6025
|
+
if ((0, import_interface_logic20.isBase64Image)(base64)) return base64;
|
|
5460
6026
|
let mimeType = null;
|
|
5461
6027
|
if (base64.startsWith("iVBORw0KGgo")) mimeType = "image/png";
|
|
5462
6028
|
else if (base64.startsWith("/9j/")) mimeType = "image/jpeg";
|
|
@@ -5465,14 +6031,14 @@ var binaryFieldController = (props) => {
|
|
|
5465
6031
|
else if (base64.startsWith("UklGR")) mimeType = "image/webp";
|
|
5466
6032
|
return mimeType ? `data:${mimeType};base64,${base64}` : null;
|
|
5467
6033
|
};
|
|
5468
|
-
(0,
|
|
6034
|
+
(0, import_react21.useEffect)(() => {
|
|
5469
6035
|
return () => {
|
|
5470
6036
|
if (selectedImage) {
|
|
5471
6037
|
URL.revokeObjectURL(selectedImage);
|
|
5472
6038
|
}
|
|
5473
6039
|
};
|
|
5474
6040
|
}, [selectedImage]);
|
|
5475
|
-
(0,
|
|
6041
|
+
(0, import_react21.useEffect)(() => {
|
|
5476
6042
|
if (binaryRef.current) {
|
|
5477
6043
|
const isInsideTable2 = !!binaryRef.current.closest("table");
|
|
5478
6044
|
setIsInsideTable(isInsideTable2);
|
|
@@ -5492,28 +6058,47 @@ var binaryFieldController = (props) => {
|
|
|
5492
6058
|
};
|
|
5493
6059
|
// Annotate the CommonJS export names for ESM import in node:
|
|
5494
6060
|
0 && (module.exports = {
|
|
6061
|
+
API_APP_URL,
|
|
6062
|
+
API_PRESCHOOL_URL,
|
|
5495
6063
|
CloseIcon,
|
|
5496
6064
|
EyeIcon,
|
|
5497
6065
|
LoadingIcon,
|
|
6066
|
+
STORAGES,
|
|
5498
6067
|
binaryFieldController,
|
|
5499
6068
|
colorFieldController,
|
|
5500
|
-
|
|
6069
|
+
combineContexts,
|
|
6070
|
+
convertFieldsToArray,
|
|
5501
6071
|
copyLinkButtonController,
|
|
6072
|
+
countSum,
|
|
5502
6073
|
dateFieldController,
|
|
5503
6074
|
downLoadBinaryController,
|
|
5504
6075
|
downloadFileController,
|
|
5505
6076
|
durationController,
|
|
5506
6077
|
floatController,
|
|
5507
6078
|
floatTimeFiledController,
|
|
6079
|
+
getDateRange,
|
|
6080
|
+
languages,
|
|
5508
6081
|
many2manyFieldController,
|
|
5509
6082
|
many2manyTagsController,
|
|
5510
6083
|
many2oneButtonController,
|
|
5511
6084
|
many2oneFieldController,
|
|
6085
|
+
mergeButtons,
|
|
5512
6086
|
priorityFieldController,
|
|
6087
|
+
setStorageItemAsync,
|
|
5513
6088
|
statusDropdownController,
|
|
6089
|
+
useAuth,
|
|
6090
|
+
useCallAction,
|
|
5514
6091
|
useClickOutside,
|
|
6092
|
+
useConfig,
|
|
5515
6093
|
useDebounce,
|
|
5516
|
-
|
|
6094
|
+
useDetail,
|
|
6095
|
+
useGetRowIds,
|
|
6096
|
+
useListData,
|
|
6097
|
+
useMenu,
|
|
6098
|
+
useProfile,
|
|
6099
|
+
useStorageState,
|
|
6100
|
+
useUser,
|
|
6101
|
+
useViewV2
|
|
5517
6102
|
});
|
|
5518
6103
|
/*! Bundled license information:
|
|
5519
6104
|
|