@fctc/widget-logic 1.1.4 → 1.1.6
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 +48 -98
- package/dist/index.d.ts +48 -98
- package/dist/index.js +828 -204
- package/dist/index.mjs +827 -180
- 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 +10 -1
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
|
|
@@ -4319,25 +4930,25 @@ var many2oneFieldController = (props) => {
|
|
|
4319
4930
|
const queryKey = [`data_${relation}`, domainObject];
|
|
4320
4931
|
const {
|
|
4321
4932
|
data: dataOfSelection,
|
|
4322
|
-
refetch,
|
|
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,12 @@ var many2oneFieldController = (props) => {
|
|
|
4348
4959
|
});
|
|
4349
4960
|
}
|
|
4350
4961
|
}, [propValue]);
|
|
4351
|
-
|
|
4352
|
-
refetch();
|
|
4353
|
-
}, [refetch]);
|
|
4354
|
-
(0, import_react4.useEffect)(() => {
|
|
4962
|
+
(0, import_react12.useEffect)(() => {
|
|
4355
4963
|
if (actionId) {
|
|
4356
4964
|
localStorage.setItem("aid", actionId);
|
|
4357
4965
|
}
|
|
4358
4966
|
}, [actionId]);
|
|
4359
|
-
const handleChooseRecord = (0,
|
|
4967
|
+
const handleChooseRecord = (0, import_react12.useCallback)(
|
|
4360
4968
|
(idRecord) => {
|
|
4361
4969
|
const newOption = options.find(
|
|
4362
4970
|
(option) => option.value === idRecord
|
|
@@ -4381,8 +4989,8 @@ var many2oneFieldController = (props) => {
|
|
|
4381
4989
|
},
|
|
4382
4990
|
[options, methods, name, onChange]
|
|
4383
4991
|
);
|
|
4384
|
-
const handleClose = (0,
|
|
4385
|
-
const handleSelectChange = (0,
|
|
4992
|
+
const handleClose = (0, import_react12.useCallback)(() => setIsShowModalMany2Many(false), []);
|
|
4993
|
+
const handleSelectChange = (0, import_react12.useCallback)(
|
|
4386
4994
|
(selectedOption) => {
|
|
4387
4995
|
if (!selectedOption) {
|
|
4388
4996
|
methods.setValue(name, null, { shouldDirty: true });
|
|
@@ -4416,13 +5024,13 @@ var many2oneFieldController = (props) => {
|
|
|
4416
5024
|
isFetching,
|
|
4417
5025
|
isShowModalMany2Many,
|
|
4418
5026
|
options,
|
|
4419
|
-
fetchMoreOptions,
|
|
5027
|
+
// fetchMoreOptions,
|
|
4420
5028
|
domainModal,
|
|
4421
5029
|
tempSelectedOption,
|
|
4422
5030
|
setTempSelectedOption,
|
|
4423
5031
|
setDomainModal,
|
|
4424
5032
|
dataOfSelection,
|
|
4425
|
-
refetch,
|
|
5033
|
+
// refetch,
|
|
4426
5034
|
selectOptions,
|
|
4427
5035
|
optionsObject,
|
|
4428
5036
|
contextObject,
|
|
@@ -4432,21 +5040,18 @@ var many2oneFieldController = (props) => {
|
|
|
4432
5040
|
};
|
|
4433
5041
|
|
|
4434
5042
|
// src/widget/basic/many2one-button-field/controller.ts
|
|
4435
|
-
var
|
|
4436
|
-
var many2oneButtonController = ({
|
|
4437
|
-
relation
|
|
4438
|
-
methods,
|
|
4439
|
-
domain
|
|
4440
|
-
}) => {
|
|
5043
|
+
var import_interface_logic11 = require("@fctc/interface-logic");
|
|
5044
|
+
var many2oneButtonController = (props) => {
|
|
5045
|
+
const { domain, methods, relation } = props;
|
|
4441
5046
|
const actionDataString = sessionStorage.getItem("actionData");
|
|
4442
|
-
const env = (0,
|
|
4443
|
-
const domainObject = (0,
|
|
5047
|
+
const env = (0, import_interface_logic11.getEnv)();
|
|
5048
|
+
const domainObject = (0, import_interface_logic11.evalJSONDomain)(domain, methods?.getValues() || {});
|
|
4444
5049
|
const actionData = actionDataString && actionDataString !== "undefined" ? JSON.parse(actionDataString) : {};
|
|
4445
|
-
const { data: dataOfSelection } = (0,
|
|
5050
|
+
const { data: dataOfSelection } = (0, import_interface_logic11.useGetSelection)({
|
|
4446
5051
|
data: {
|
|
4447
5052
|
model: relation ?? "",
|
|
4448
5053
|
domain: domainObject,
|
|
4449
|
-
context: { ...env.context, ...(0,
|
|
5054
|
+
context: { ...env.context, ...(0, import_interface_logic11.evalJSONContext)(actionData?.context) }
|
|
4450
5055
|
},
|
|
4451
5056
|
queryKey: [`data_${relation}`, domainObject]
|
|
4452
5057
|
});
|
|
@@ -4460,26 +5065,22 @@ var many2oneButtonController = ({
|
|
|
4460
5065
|
};
|
|
4461
5066
|
|
|
4462
5067
|
// src/widget/basic/many2many-field/controller.ts
|
|
4463
|
-
var
|
|
4464
|
-
var
|
|
5068
|
+
var import_react16 = require("react");
|
|
5069
|
+
var import_interface_logic16 = require("@fctc/interface-logic");
|
|
4465
5070
|
|
|
4466
|
-
// src/widget/table/
|
|
4467
|
-
var
|
|
4468
|
-
var
|
|
4469
|
-
|
|
4470
|
-
|
|
4471
|
-
|
|
4472
|
-
|
|
4473
|
-
|
|
4474
|
-
|
|
4475
|
-
|
|
4476
|
-
|
|
4477
|
-
|
|
4478
|
-
|
|
4479
|
-
}
|
|
4480
|
-
var useTableHandler = ({ data }) => {
|
|
4481
|
-
const [rows, setRows] = (0, import_react5.useState)(data.records || []);
|
|
4482
|
-
const [columns, setColumns] = (0, import_react5.useState)([]);
|
|
5071
|
+
// src/widget/advance/table/table-body/controller.ts
|
|
5072
|
+
var import_interface_logic12 = require("@fctc/interface-logic");
|
|
5073
|
+
var import_react13 = require("react");
|
|
5074
|
+
|
|
5075
|
+
// src/widget/advance/table/table-head/controller.ts
|
|
5076
|
+
var import_interface_logic13 = require("@fctc/interface-logic");
|
|
5077
|
+
|
|
5078
|
+
// src/widget/advance/table/table-view/controller.ts
|
|
5079
|
+
var import_interface_logic14 = require("@fctc/interface-logic");
|
|
5080
|
+
var import_react14 = require("react");
|
|
5081
|
+
var tableController = ({ data }) => {
|
|
5082
|
+
const [rows, setRows] = (0, import_react14.useState)(data.records || []);
|
|
5083
|
+
const [columns, setColumns] = (0, import_react14.useState)([]);
|
|
4483
5084
|
const dataModelFields = data.fields?.map((field) => {
|
|
4484
5085
|
return {
|
|
4485
5086
|
...data.dataModel?.[field?.name],
|
|
@@ -4507,14 +5108,14 @@ var useTableHandler = ({ data }) => {
|
|
|
4507
5108
|
return item.display_name ? { ...transformedItem, item: item.display_name } : transformedItem;
|
|
4508
5109
|
});
|
|
4509
5110
|
};
|
|
4510
|
-
(0,
|
|
5111
|
+
(0, import_react14.useEffect)(() => {
|
|
4511
5112
|
setRows(transformData(data.records || null));
|
|
4512
5113
|
}, [data.records]);
|
|
4513
5114
|
const handleGetColumns = () => {
|
|
4514
5115
|
let cols = [];
|
|
4515
5116
|
try {
|
|
4516
5117
|
cols = mergeFields?.filter((item) => {
|
|
4517
|
-
return item?.widget !== "details_Receive_money" && !(item?.column_invisible ?
|
|
5118
|
+
return item?.widget !== "details_Receive_money" && !(item?.column_invisible ? import_interface_logic14.domainHelper.matchDomains(data.context, item?.column_invisible) : item?.invisible ? import_interface_logic14.domainHelper.matchDomains(data.context, item?.invisible) : false);
|
|
4518
5119
|
})?.map((field) => {
|
|
4519
5120
|
return {
|
|
4520
5121
|
name: field?.name,
|
|
@@ -4528,7 +5129,7 @@ var useTableHandler = ({ data }) => {
|
|
|
4528
5129
|
}
|
|
4529
5130
|
return cols;
|
|
4530
5131
|
};
|
|
4531
|
-
(0,
|
|
5132
|
+
(0, import_react14.useEffect)(() => {
|
|
4532
5133
|
const columns2 = handleGetColumns();
|
|
4533
5134
|
setColumns(columns2);
|
|
4534
5135
|
}, [data.records]);
|
|
@@ -4552,6 +5153,32 @@ var useTableHandler = ({ data }) => {
|
|
|
4552
5153
|
};
|
|
4553
5154
|
};
|
|
4554
5155
|
|
|
5156
|
+
// src/widget/advance/table/table-group/controller.ts
|
|
5157
|
+
var import_interface_logic15 = require("@fctc/interface-logic");
|
|
5158
|
+
var import_react15 = require("react");
|
|
5159
|
+
|
|
5160
|
+
// src/utils/i18n.ts
|
|
5161
|
+
var import_react_i18next2 = require("react-i18next");
|
|
5162
|
+
var import_i18next = __toESM(require("i18next"));
|
|
5163
|
+
var import_i18next_browser_languagedetector = __toESM(require("i18next-browser-languagedetector"));
|
|
5164
|
+
import_i18next.default.use(import_i18next_browser_languagedetector.default).use(import_react_i18next2.initReactI18next).init({
|
|
5165
|
+
resources: {
|
|
5166
|
+
vi: { translation: vi },
|
|
5167
|
+
en: { translation: en }
|
|
5168
|
+
},
|
|
5169
|
+
fallbackLng: "vi",
|
|
5170
|
+
lng: "vi_VN",
|
|
5171
|
+
debug: false,
|
|
5172
|
+
nonExplicitSupportedLngs: true,
|
|
5173
|
+
interpolation: {
|
|
5174
|
+
escapeValue: false
|
|
5175
|
+
},
|
|
5176
|
+
detection: {
|
|
5177
|
+
caches: ["cookie"]
|
|
5178
|
+
}
|
|
5179
|
+
});
|
|
5180
|
+
var i18n_default = import_i18next.default;
|
|
5181
|
+
|
|
4555
5182
|
// src/widget/basic/many2many-field/controller.ts
|
|
4556
5183
|
var many2manyFieldController = (props) => {
|
|
4557
5184
|
const {
|
|
@@ -4561,7 +5188,7 @@ var many2manyFieldController = (props) => {
|
|
|
4561
5188
|
tab,
|
|
4562
5189
|
model,
|
|
4563
5190
|
aid,
|
|
4564
|
-
setSelectedRowKeys,
|
|
5191
|
+
setSelectedRowKeys: setSelectedRowKeys4,
|
|
4565
5192
|
fields,
|
|
4566
5193
|
setFields,
|
|
4567
5194
|
groupByDomain,
|
|
@@ -4569,17 +5196,17 @@ var many2manyFieldController = (props) => {
|
|
|
4569
5196
|
options,
|
|
4570
5197
|
sessionStorageUtils
|
|
4571
5198
|
} = props;
|
|
4572
|
-
const appDispatch = (0,
|
|
5199
|
+
const appDispatch = (0, import_interface_logic16.useAppDispatch)();
|
|
4573
5200
|
const actionData = sessionStorageUtils.getActionData();
|
|
4574
5201
|
const [debouncedPage] = useDebounce(page, 500);
|
|
4575
|
-
const [order, setOrder] = (0,
|
|
4576
|
-
const [isLoadedData, setIsLoadedData] = (0,
|
|
4577
|
-
const [domainMany2Many, setDomainMany2Many] = (0,
|
|
4578
|
-
const env = (0,
|
|
5202
|
+
const [order, setOrder] = (0, import_react16.useState)();
|
|
5203
|
+
const [isLoadedData, setIsLoadedData] = (0, import_react16.useState)(false);
|
|
5204
|
+
const [domainMany2Many, setDomainMany2Many] = (0, import_react16.useState)(domain);
|
|
5205
|
+
const env = (0, import_interface_logic16.getEnv)();
|
|
4579
5206
|
const {
|
|
4580
5207
|
// tableHead,
|
|
4581
5208
|
selectedTags
|
|
4582
|
-
} = (0,
|
|
5209
|
+
} = (0, import_interface_logic16.useAppSelector)(import_interface_logic16.selectSearch);
|
|
4583
5210
|
const viewParams = {
|
|
4584
5211
|
model: relation,
|
|
4585
5212
|
views: [
|
|
@@ -4588,11 +5215,11 @@ var many2manyFieldController = (props) => {
|
|
|
4588
5215
|
],
|
|
4589
5216
|
context
|
|
4590
5217
|
};
|
|
4591
|
-
const { data: viewResponse, isFetched: isViewReponseFetched } = (0,
|
|
5218
|
+
const { data: viewResponse, isFetched: isViewReponseFetched } = (0, import_interface_logic16.useGetView)(
|
|
4592
5219
|
viewParams,
|
|
4593
5220
|
actionData
|
|
4594
5221
|
);
|
|
4595
|
-
const baseModel = (0,
|
|
5222
|
+
const baseModel = (0, import_react16.useMemo)(
|
|
4596
5223
|
() => ({
|
|
4597
5224
|
name: String(relation),
|
|
4598
5225
|
view: viewResponse || {},
|
|
@@ -4604,26 +5231,26 @@ var many2manyFieldController = (props) => {
|
|
|
4604
5231
|
}),
|
|
4605
5232
|
[model, viewResponse]
|
|
4606
5233
|
);
|
|
4607
|
-
const initModel = (0,
|
|
4608
|
-
const modelInstance = (0,
|
|
5234
|
+
const initModel = (0, import_interface_logic16.useModel)();
|
|
5235
|
+
const modelInstance = (0, import_react16.useMemo)(() => {
|
|
4609
5236
|
if (viewResponse) {
|
|
4610
5237
|
return initModel.initModel(baseModel);
|
|
4611
5238
|
}
|
|
4612
5239
|
return null;
|
|
4613
5240
|
}, [baseModel, viewResponse]);
|
|
4614
|
-
const specification = (0,
|
|
5241
|
+
const specification = (0, import_react16.useMemo)(() => {
|
|
4615
5242
|
if (modelInstance) {
|
|
4616
5243
|
return modelInstance.getSpecification();
|
|
4617
5244
|
}
|
|
4618
5245
|
return null;
|
|
4619
5246
|
}, [modelInstance]);
|
|
4620
5247
|
const default_order = viewResponse && viewResponse?.views?.list?.default_order;
|
|
4621
|
-
const optionsObject = tab?.options ? (0,
|
|
5248
|
+
const optionsObject = tab?.options ? (0, import_interface_logic16.evalJSONContext)(tab?.options) : (options ? (0, import_interface_logic16.evalJSONContext)(options) : {}) || {};
|
|
4622
5249
|
const fetchData = async () => {
|
|
4623
5250
|
try {
|
|
4624
5251
|
setDomainMany2Many(domain);
|
|
4625
|
-
appDispatch((0,
|
|
4626
|
-
appDispatch((0,
|
|
5252
|
+
appDispatch((0, import_interface_logic16.setFirstDomain)(domain));
|
|
5253
|
+
appDispatch((0, import_interface_logic16.setViewDataStore)(viewResponse));
|
|
4627
5254
|
const modalData = viewResponse?.views?.list?.fields.map((field) => ({
|
|
4628
5255
|
...viewResponse?.models?.[String(model)]?.[field?.name],
|
|
4629
5256
|
...field
|
|
@@ -4634,7 +5261,7 @@ var many2manyFieldController = (props) => {
|
|
|
4634
5261
|
[`${aid}_${relation}_popupmany2many`]: modalData
|
|
4635
5262
|
});
|
|
4636
5263
|
}
|
|
4637
|
-
appDispatch((0,
|
|
5264
|
+
appDispatch((0, import_interface_logic16.setPage)(0));
|
|
4638
5265
|
} catch (err) {
|
|
4639
5266
|
console.log(err);
|
|
4640
5267
|
}
|
|
@@ -4656,7 +5283,7 @@ var many2manyFieldController = (props) => {
|
|
|
4656
5283
|
context,
|
|
4657
5284
|
fields: groupByDomain?.fields,
|
|
4658
5285
|
groupby: [groupByDomain?.contexts[0]?.group_by],
|
|
4659
|
-
sort: order ? order : default_order ? (0,
|
|
5286
|
+
sort: order ? order : default_order ? (0, import_interface_logic16.formatSortingString)(default_order) : ""
|
|
4660
5287
|
};
|
|
4661
5288
|
const enabled = isLoadedData && !!specification && !!relation && !!domainMany2Many && !!viewResponse;
|
|
4662
5289
|
const {
|
|
@@ -4664,24 +5291,24 @@ var many2manyFieldController = (props) => {
|
|
|
4664
5291
|
isLoading: isDataLoading,
|
|
4665
5292
|
isFetched: isDataResponseFetched,
|
|
4666
5293
|
isPlaceholderData
|
|
4667
|
-
} = (0,
|
|
4668
|
-
(0,
|
|
5294
|
+
} = (0, import_interface_logic16.useGetListData)(data, queryKey, enabled);
|
|
5295
|
+
(0, import_react16.useEffect)(() => {
|
|
4669
5296
|
if (viewResponse) {
|
|
4670
5297
|
fetchData();
|
|
4671
5298
|
}
|
|
4672
5299
|
return () => {
|
|
4673
|
-
appDispatch((0,
|
|
5300
|
+
appDispatch((0, import_interface_logic16.setGroupByDomain)(null));
|
|
4674
5301
|
setFields((prevFields) => ({
|
|
4675
5302
|
...prevFields,
|
|
4676
5303
|
[`${aid}_${relation}_popupmany2many`]: null
|
|
4677
5304
|
}));
|
|
4678
|
-
appDispatch((0,
|
|
4679
|
-
|
|
5305
|
+
appDispatch((0, import_interface_logic16.setPage)(0));
|
|
5306
|
+
setSelectedRowKeys4([]);
|
|
4680
5307
|
setDomainMany2Many(null);
|
|
4681
5308
|
setIsLoadedData(false);
|
|
4682
5309
|
};
|
|
4683
5310
|
}, [viewResponse]);
|
|
4684
|
-
const { rows, columns, typeTable } =
|
|
5311
|
+
const { rows, columns, typeTable } = tableController({
|
|
4685
5312
|
data: {
|
|
4686
5313
|
fields: fields?.[`${aid}_${relation}_popupmany2many`] || viewResponse?.views?.list?.fields,
|
|
4687
5314
|
records: dataResponse?.records ?? dataResponse?.groups,
|
|
@@ -4699,18 +5326,18 @@ var many2manyFieldController = (props) => {
|
|
|
4699
5326
|
refetch,
|
|
4700
5327
|
data: dataFormViewResponse,
|
|
4701
5328
|
isSuccess
|
|
4702
|
-
} = (0,
|
|
5329
|
+
} = (0, import_interface_logic16.useGetFormView)({
|
|
4703
5330
|
data: dataFormView,
|
|
4704
5331
|
queryKey: [`form-view-action-${relation}`],
|
|
4705
5332
|
enabled: false
|
|
4706
5333
|
});
|
|
4707
|
-
(0,
|
|
5334
|
+
(0, import_react16.useEffect)(() => {
|
|
4708
5335
|
if (isSuccess && dataFormViewResponse) {
|
|
4709
5336
|
sessionStorage.setItem("actionData", JSON.stringify(dataFormViewResponse));
|
|
4710
5337
|
window.location.href = `/form/menu?model=${relation}`;
|
|
4711
5338
|
}
|
|
4712
5339
|
}, [isSuccess]);
|
|
4713
|
-
(0,
|
|
5340
|
+
(0, import_react16.useEffect)(() => {
|
|
4714
5341
|
if (domainMany2Many && !isLoadedData) {
|
|
4715
5342
|
setIsLoadedData(true);
|
|
4716
5343
|
}
|
|
@@ -4756,8 +5383,8 @@ var many2manyFieldController = (props) => {
|
|
|
4756
5383
|
};
|
|
4757
5384
|
|
|
4758
5385
|
// src/widget/basic/many2many-tags-field/controller.ts
|
|
4759
|
-
var
|
|
4760
|
-
var
|
|
5386
|
+
var import_react17 = require("react");
|
|
5387
|
+
var import_interface_logic17 = require("@fctc/interface-logic");
|
|
4761
5388
|
var many2manyTagsController = (props) => {
|
|
4762
5389
|
const {
|
|
4763
5390
|
relation,
|
|
@@ -4768,10 +5395,10 @@ var many2manyTagsController = (props) => {
|
|
|
4768
5395
|
placeholderNoOption
|
|
4769
5396
|
} = props;
|
|
4770
5397
|
const isUser = relation === "res.users" || relation === "res.partner";
|
|
4771
|
-
const env = (0,
|
|
4772
|
-
const addtionalFields = optionsFields ? (0,
|
|
4773
|
-
const domainObject = (0,
|
|
4774
|
-
() => (0,
|
|
5398
|
+
const env = (0, import_interface_logic17.getEnv)();
|
|
5399
|
+
const addtionalFields = optionsFields ? (0, import_interface_logic17.evalJSONContext)(optionsFields) : null;
|
|
5400
|
+
const domainObject = (0, import_react17.useMemo)(
|
|
5401
|
+
() => (0, import_interface_logic17.evalJSONDomain)(domain, JSON.parse(JSON.stringify(formValues || {}))),
|
|
4775
5402
|
[domain, formValues]
|
|
4776
5403
|
);
|
|
4777
5404
|
const data = {
|
|
@@ -4781,13 +5408,13 @@ var many2manyTagsController = (props) => {
|
|
|
4781
5408
|
id: {},
|
|
4782
5409
|
name: {},
|
|
4783
5410
|
display_name: {},
|
|
4784
|
-
...widget &&
|
|
4785
|
-
...widget &&
|
|
5411
|
+
...widget && import_interface_logic17.WIDGETAVATAR[widget] ? { image_256: {} } : {},
|
|
5412
|
+
...widget && import_interface_logic17.WIDGETCOLOR[widget] && addtionalFields?.color_field ? { color: {} } : {}
|
|
4786
5413
|
},
|
|
4787
5414
|
enabled: true,
|
|
4788
5415
|
context: env.context
|
|
4789
5416
|
};
|
|
4790
|
-
const { data: dataOfSelection } = (0,
|
|
5417
|
+
const { data: dataOfSelection } = (0, import_interface_logic17.useGetSelection)({
|
|
4791
5418
|
data,
|
|
4792
5419
|
queryKey: [`data_${relation}`, domainObject]
|
|
4793
5420
|
});
|
|
@@ -4813,8 +5440,8 @@ var many2manyTagsController = (props) => {
|
|
|
4813
5440
|
};
|
|
4814
5441
|
|
|
4815
5442
|
// src/widget/basic/status-bar-field/controller.ts
|
|
4816
|
-
var
|
|
4817
|
-
var
|
|
5443
|
+
var import_react18 = require("react");
|
|
5444
|
+
var import_interface_logic18 = require("@fctc/interface-logic");
|
|
4818
5445
|
var durationController = (props) => {
|
|
4819
5446
|
const {
|
|
4820
5447
|
relation,
|
|
@@ -4831,14 +5458,14 @@ var durationController = (props) => {
|
|
|
4831
5458
|
name: "",
|
|
4832
5459
|
fold: ""
|
|
4833
5460
|
};
|
|
4834
|
-
const [disabled, setDisabled] = (0,
|
|
4835
|
-
const [modelStatus, setModalStatus] = (0,
|
|
4836
|
-
const { context } = (0,
|
|
5461
|
+
const [disabled, setDisabled] = (0, import_react18.useState)(false);
|
|
5462
|
+
const [modelStatus, setModalStatus] = (0, import_react18.useState)(false);
|
|
5463
|
+
const { context } = (0, import_interface_logic18.useAppSelector)(import_interface_logic18.selectEnv);
|
|
4837
5464
|
const queryKey = [`data-status-duration`, specification];
|
|
4838
5465
|
const listDataProps = {
|
|
4839
5466
|
model: relation,
|
|
4840
5467
|
specification,
|
|
4841
|
-
domain: (0,
|
|
5468
|
+
domain: (0, import_interface_logic18.evalJSONDomain)(domain, JSON.parse(JSON.stringify(formValues))),
|
|
4842
5469
|
limit: 10,
|
|
4843
5470
|
offset: 0,
|
|
4844
5471
|
fields: "",
|
|
@@ -4848,8 +5475,8 @@ var durationController = (props) => {
|
|
|
4848
5475
|
},
|
|
4849
5476
|
sort: ""
|
|
4850
5477
|
};
|
|
4851
|
-
const { data: dataResponse } = (0,
|
|
4852
|
-
const { mutate: fetchChangeStatus } = (0,
|
|
5478
|
+
const { data: dataResponse } = (0, import_interface_logic18.useGetListData)(listDataProps, queryKey);
|
|
5479
|
+
const { mutate: fetchChangeStatus } = (0, import_interface_logic18.useChangeStatus)();
|
|
4853
5480
|
const handleClick = async (stage_id) => {
|
|
4854
5481
|
setDisabled(true);
|
|
4855
5482
|
if (stage_id) {
|
|
@@ -4885,26 +5512,26 @@ var durationController = (props) => {
|
|
|
4885
5512
|
};
|
|
4886
5513
|
|
|
4887
5514
|
// src/widget/basic/priority-field/controller.ts
|
|
4888
|
-
var
|
|
5515
|
+
var import_interface_logic19 = require("@fctc/interface-logic");
|
|
4889
5516
|
var priorityFieldController = (props) => {
|
|
4890
5517
|
const {
|
|
4891
5518
|
value,
|
|
4892
|
-
selection,
|
|
4893
5519
|
isForm,
|
|
4894
5520
|
name,
|
|
4895
5521
|
methods,
|
|
4896
|
-
id,
|
|
4897
5522
|
onChange,
|
|
4898
5523
|
model,
|
|
5524
|
+
selection,
|
|
5525
|
+
id,
|
|
4899
5526
|
actionData,
|
|
4900
5527
|
viewData,
|
|
4901
5528
|
context
|
|
4902
5529
|
} = props;
|
|
4903
|
-
const _context = { ...(0,
|
|
5530
|
+
const _context = { ...(0, import_interface_logic19.evalJSONContext)(actionData?.context) };
|
|
4904
5531
|
const contextObject = { ...context, ..._context };
|
|
4905
5532
|
const defaultPriority = parseInt(value) + 1;
|
|
4906
5533
|
const label = viewData?.models?.[model]?.[name ?? ""]?.string ?? name;
|
|
4907
|
-
const { mutateAsync: fetchSave } = (0,
|
|
5534
|
+
const { mutateAsync: fetchSave } = (0, import_interface_logic19.useSave)();
|
|
4908
5535
|
const savePriorities = async ({
|
|
4909
5536
|
value: value2,
|
|
4910
5537
|
resetPriority
|
|
@@ -4939,8 +5566,8 @@ var priorityFieldController = (props) => {
|
|
|
4939
5566
|
};
|
|
4940
5567
|
|
|
4941
5568
|
// src/widget/basic/float-time-field/controller.ts
|
|
4942
|
-
var
|
|
4943
|
-
var
|
|
5569
|
+
var import_react19 = require("react");
|
|
5570
|
+
var import_interface_logic20 = require("@fctc/interface-logic");
|
|
4944
5571
|
var floatTimeFiledController = ({
|
|
4945
5572
|
onChange: fieldOnChange,
|
|
4946
5573
|
onBlur,
|
|
@@ -4949,11 +5576,11 @@ var floatTimeFiledController = ({
|
|
|
4949
5576
|
props
|
|
4950
5577
|
}) => {
|
|
4951
5578
|
const { name, defaultValue = 0, onChange } = props;
|
|
4952
|
-
const [input, setInput] = (0,
|
|
4953
|
-
(0,
|
|
5579
|
+
const [input, setInput] = (0, import_react19.useState)(
|
|
5580
|
+
(0, import_interface_logic20.convertFloatToTime)(value ?? defaultValue)
|
|
4954
5581
|
);
|
|
4955
|
-
const [formattedTime, setFormattedTime] = (0,
|
|
4956
|
-
const [errors, setErrors] = (0,
|
|
5582
|
+
const [formattedTime, setFormattedTime] = (0, import_react19.useState)("");
|
|
5583
|
+
const [errors, setErrors] = (0, import_react19.useState)("");
|
|
4957
5584
|
const handleInputChange = (e) => {
|
|
4958
5585
|
const raw = e.target.value.replace(/[^\d:]/g, "");
|
|
4959
5586
|
setInput(raw);
|
|
@@ -4983,7 +5610,7 @@ var floatTimeFiledController = ({
|
|
|
4983
5610
|
if (!isDirty) return;
|
|
4984
5611
|
if (formattedTime) {
|
|
4985
5612
|
setInput(formattedTime);
|
|
4986
|
-
const floatVal = (0,
|
|
5613
|
+
const floatVal = (0, import_interface_logic20.convertTimeToFloat)(formattedTime);
|
|
4987
5614
|
fieldOnChange(floatVal);
|
|
4988
5615
|
if (onChange) {
|
|
4989
5616
|
onChange(name ?? "", floatVal);
|
|
@@ -5026,7 +5653,7 @@ var floatTimeFiledController = ({
|
|
|
5026
5653
|
};
|
|
5027
5654
|
|
|
5028
5655
|
// src/widget/basic/float-field/controller.ts
|
|
5029
|
-
var
|
|
5656
|
+
var import_react20 = require("react");
|
|
5030
5657
|
var floatController = ({
|
|
5031
5658
|
onChange,
|
|
5032
5659
|
value,
|
|
@@ -5034,10 +5661,10 @@ var floatController = ({
|
|
|
5034
5661
|
}) => {
|
|
5035
5662
|
const { name, required, methods, onChange: handleOnchange, string } = props;
|
|
5036
5663
|
const { setError, clearErrors } = methods;
|
|
5037
|
-
const [inputValue, setInputValue] = (0,
|
|
5664
|
+
const [inputValue, setInputValue] = (0, import_react20.useState)(
|
|
5038
5665
|
value !== void 0 && value !== null ? useFormatFloatNumber(value) : ""
|
|
5039
5666
|
);
|
|
5040
|
-
(0,
|
|
5667
|
+
(0, import_react20.useEffect)(() => {
|
|
5041
5668
|
if (value !== void 0 && value !== null && value !== parseFloat(inputValue?.replace(/,/g, ""))) {
|
|
5042
5669
|
setInputValue(useFormatFloatNumber(value));
|
|
5043
5670
|
clearErrors(name);
|
|
@@ -5045,9 +5672,9 @@ var floatController = ({
|
|
|
5045
5672
|
setInputValue("");
|
|
5046
5673
|
}
|
|
5047
5674
|
}, [value, name, clearErrors]);
|
|
5048
|
-
const isDirtyRef = (0,
|
|
5049
|
-
const inputRef = (0,
|
|
5050
|
-
const lastCommittedValueRef = (0,
|
|
5675
|
+
const isDirtyRef = (0, import_react20.useRef)(false);
|
|
5676
|
+
const inputRef = (0, import_react20.useRef)(null);
|
|
5677
|
+
const lastCommittedValueRef = (0, import_react20.useRef)(null);
|
|
5051
5678
|
const handleInputChange = (e) => {
|
|
5052
5679
|
const newValue = e.target.value;
|
|
5053
5680
|
const valueWithoutCommas = newValue.replace(/,/g, "");
|
|
@@ -5065,8 +5692,8 @@ var floatController = ({
|
|
|
5065
5692
|
if (!isNaN(parsedValue)) {
|
|
5066
5693
|
if (parsedValue < 0) {
|
|
5067
5694
|
setError(name, {
|
|
5068
|
-
type: "validate"
|
|
5069
|
-
|
|
5695
|
+
type: "validate",
|
|
5696
|
+
message: i18n_default.t("invalid_number")
|
|
5070
5697
|
});
|
|
5071
5698
|
} else {
|
|
5072
5699
|
onChange(parsedValue);
|
|
@@ -5089,8 +5716,8 @@ var floatController = ({
|
|
|
5089
5716
|
if (rawValue === "" || rawValue === ".") {
|
|
5090
5717
|
if (required) {
|
|
5091
5718
|
setError(name, {
|
|
5092
|
-
type: "required"
|
|
5093
|
-
|
|
5719
|
+
type: "required",
|
|
5720
|
+
message: `${string} ${i18n_default.t("must_required")}`
|
|
5094
5721
|
});
|
|
5095
5722
|
}
|
|
5096
5723
|
onChange(null);
|
|
@@ -5099,8 +5726,8 @@ var floatController = ({
|
|
|
5099
5726
|
} else if (!isNaN(parsedValue)) {
|
|
5100
5727
|
if (parsedValue < 0) {
|
|
5101
5728
|
setError(name, {
|
|
5102
|
-
type: "validate"
|
|
5103
|
-
|
|
5729
|
+
type: "validate",
|
|
5730
|
+
message: i18n_default.t("invalid_number")
|
|
5104
5731
|
});
|
|
5105
5732
|
setInputValue("");
|
|
5106
5733
|
lastCommittedValueRef.current = null;
|
|
@@ -5120,8 +5747,8 @@ var floatController = ({
|
|
|
5120
5747
|
}
|
|
5121
5748
|
} else {
|
|
5122
5749
|
setError(name, {
|
|
5123
|
-
type: "validate"
|
|
5124
|
-
|
|
5750
|
+
type: "validate",
|
|
5751
|
+
message: i18n_default.t("invalid_number")
|
|
5125
5752
|
});
|
|
5126
5753
|
setInputValue("");
|
|
5127
5754
|
lastCommittedValueRef.current = null;
|
|
@@ -5148,10 +5775,10 @@ var useFormatFloatNumber = (value) => {
|
|
|
5148
5775
|
};
|
|
5149
5776
|
|
|
5150
5777
|
// src/widget/basic/download-file-field/controller.ts
|
|
5151
|
-
var
|
|
5778
|
+
var import_react21 = require("react");
|
|
5152
5779
|
var downloadFileController = () => {
|
|
5153
|
-
const inputId = (0,
|
|
5154
|
-
const [file, setFile] = (0,
|
|
5780
|
+
const inputId = (0, import_react21.useId)();
|
|
5781
|
+
const [file, setFile] = (0, import_react21.useState)(null);
|
|
5155
5782
|
const handleFileChange = (e) => {
|
|
5156
5783
|
setFile(e.target.files[0]);
|
|
5157
5784
|
};
|
|
@@ -5219,8 +5846,8 @@ var dateFieldController = (props) => {
|
|
|
5219
5846
|
widget,
|
|
5220
5847
|
min,
|
|
5221
5848
|
max,
|
|
5222
|
-
formValues,
|
|
5223
5849
|
viewData,
|
|
5850
|
+
formValues,
|
|
5224
5851
|
model
|
|
5225
5852
|
} = props;
|
|
5226
5853
|
const range = (start, end, step = 1) => {
|
|
@@ -5275,18 +5902,30 @@ var dateFieldController = (props) => {
|
|
|
5275
5902
|
const compareNow = showTime ? now : now.clone().startOf("day");
|
|
5276
5903
|
if (minNowValue) {
|
|
5277
5904
|
if (compareSelected.isBefore(compareNow) && typeof minNowValue === "boolean" && minNowValue === true) {
|
|
5905
|
+
return `${i18n_default.t("please_enter")} ${string} ${i18n_default.t(
|
|
5906
|
+
"greater_or_equal_now"
|
|
5907
|
+
)}`;
|
|
5278
5908
|
} else if (import_moment.default.isMoment(minNowValue)) {
|
|
5279
5909
|
const compareMin = showTime ? minNowValue : minNowValue.clone().startOf("day");
|
|
5280
5910
|
if (compareSelected.isBefore(compareMin)) {
|
|
5281
5911
|
const fieldRelationDate = viewData?.models?.[model]?.[min ?? ""];
|
|
5912
|
+
return `${i18n_default.t("please_enter")} ${string} ${i18n_default.t(
|
|
5913
|
+
"greater_or_equal"
|
|
5914
|
+
)} ${fieldRelationDate?.string}`;
|
|
5282
5915
|
}
|
|
5283
5916
|
}
|
|
5284
5917
|
} else if (maxNowValue) {
|
|
5285
5918
|
if (compareSelected.isAfter(compareNow) && typeof maxNowValue === "boolean" && maxNowValue === true) {
|
|
5919
|
+
return `${i18n_default.t("please_enter")} ${string} ${i18n_default.t(
|
|
5920
|
+
"less_or_equal_now"
|
|
5921
|
+
)}`;
|
|
5286
5922
|
} else if (import_moment.default.isMoment(maxNowValue)) {
|
|
5287
5923
|
const compareMax = showTime ? maxNowValue : maxNowValue.clone().startOf("day");
|
|
5288
5924
|
if (compareSelected.isAfter(compareMax)) {
|
|
5289
5925
|
const fieldRelationDate = viewData?.models?.[model]?.[max ?? ""];
|
|
5926
|
+
return `${i18n_default.t("please_enter")} ${string} ${i18n_default.t(
|
|
5927
|
+
"less_or_equal"
|
|
5928
|
+
)} ${fieldRelationDate?.string}`;
|
|
5290
5929
|
}
|
|
5291
5930
|
}
|
|
5292
5931
|
}
|
|
@@ -5309,13 +5948,13 @@ var dateFieldController = (props) => {
|
|
|
5309
5948
|
};
|
|
5310
5949
|
|
|
5311
5950
|
// src/widget/basic/copy-link-button/controller.ts
|
|
5312
|
-
var
|
|
5313
|
-
var
|
|
5951
|
+
var import_react22 = require("react");
|
|
5952
|
+
var import_interface_logic21 = require("@fctc/interface-logic");
|
|
5314
5953
|
var copyLinkButtonController = (props) => {
|
|
5315
5954
|
const { value, defaultValue } = props;
|
|
5316
|
-
const [isCopied, setIsCopied] = (0,
|
|
5955
|
+
const [isCopied, setIsCopied] = (0, import_react22.useState)(false);
|
|
5317
5956
|
const handleCopyToClipboard = async (value2) => {
|
|
5318
|
-
await (0,
|
|
5957
|
+
await (0, import_interface_logic21.copyTextToClipboard)(value2);
|
|
5319
5958
|
setIsCopied(true);
|
|
5320
5959
|
setTimeout(() => setIsCopied(false), 2e3);
|
|
5321
5960
|
};
|
|
@@ -5327,49 +5966,15 @@ var copyLinkButtonController = (props) => {
|
|
|
5327
5966
|
};
|
|
5328
5967
|
};
|
|
5329
5968
|
|
|
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
5969
|
// src/widget/basic/color-field/color-controller.ts
|
|
5365
|
-
var
|
|
5970
|
+
var import_interface_logic22 = require("@fctc/interface-logic");
|
|
5366
5971
|
var colorFieldController = (props) => {
|
|
5367
5972
|
const { value, isForm, name, formValues, idForm, model, actionData } = props;
|
|
5368
|
-
const env = (0,
|
|
5369
|
-
const _context = { ...(0,
|
|
5973
|
+
const env = (0, import_interface_logic22.getEnv)();
|
|
5974
|
+
const _context = { ...(0, import_interface_logic22.evalJSONContext)(actionData?.context) || {} };
|
|
5370
5975
|
const contextObject = { ...env.context, ..._context };
|
|
5371
5976
|
const idDefault = isForm ? idForm : formValues?.id;
|
|
5372
|
-
const { mutate: onSave } = (0,
|
|
5977
|
+
const { mutate: onSave } = (0, import_interface_logic22.useSave)();
|
|
5373
5978
|
const savePickColor = async (colorObject) => {
|
|
5374
5979
|
const { id } = colorObject;
|
|
5375
5980
|
if (value === id) return;
|
|
@@ -5394,16 +5999,16 @@ var colorFieldController = (props) => {
|
|
|
5394
5999
|
};
|
|
5395
6000
|
|
|
5396
6001
|
// src/widget/basic/binary-field/controller.ts
|
|
5397
|
-
var
|
|
5398
|
-
var
|
|
6002
|
+
var import_react23 = require("react");
|
|
6003
|
+
var import_interface_logic23 = require("@fctc/interface-logic");
|
|
5399
6004
|
var binaryFieldController = (props) => {
|
|
5400
6005
|
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,
|
|
6006
|
+
const inputId = (0, import_react23.useId)();
|
|
6007
|
+
const [selectedImage, setSelectedImage] = (0, import_react23.useState)(null);
|
|
6008
|
+
const [initialImage, setInitialImage] = (0, import_react23.useState)(value || null);
|
|
6009
|
+
const [isInsideTable, setIsInsideTable] = (0, import_react23.useState)(false);
|
|
5405
6010
|
const { setValue } = methods;
|
|
5406
|
-
const binaryRef = (0,
|
|
6011
|
+
const binaryRef = (0, import_react23.useRef)(null);
|
|
5407
6012
|
const convertUrlToBase64 = async (url) => {
|
|
5408
6013
|
try {
|
|
5409
6014
|
const response = await fetch(url);
|
|
@@ -5452,11 +6057,11 @@ var binaryFieldController = (props) => {
|
|
|
5452
6057
|
};
|
|
5453
6058
|
const checkIsImageLink = (url) => {
|
|
5454
6059
|
const imageExtensions = /\.(jpg|jpeg|png|gif|bmp|webp|svg|tiff|ico)$/i;
|
|
5455
|
-
return imageExtensions.test(url) || (0,
|
|
6060
|
+
return imageExtensions.test(url) || (0, import_interface_logic23.isBase64Image)(url) || isBlobUrl(url);
|
|
5456
6061
|
};
|
|
5457
6062
|
const getImageBase64WithMimeType = (base64) => {
|
|
5458
6063
|
if (typeof base64 !== "string" || base64.length < 10) return null;
|
|
5459
|
-
if ((0,
|
|
6064
|
+
if ((0, import_interface_logic23.isBase64Image)(base64)) return base64;
|
|
5460
6065
|
let mimeType = null;
|
|
5461
6066
|
if (base64.startsWith("iVBORw0KGgo")) mimeType = "image/png";
|
|
5462
6067
|
else if (base64.startsWith("/9j/")) mimeType = "image/jpeg";
|
|
@@ -5465,14 +6070,14 @@ var binaryFieldController = (props) => {
|
|
|
5465
6070
|
else if (base64.startsWith("UklGR")) mimeType = "image/webp";
|
|
5466
6071
|
return mimeType ? `data:${mimeType};base64,${base64}` : null;
|
|
5467
6072
|
};
|
|
5468
|
-
(0,
|
|
6073
|
+
(0, import_react23.useEffect)(() => {
|
|
5469
6074
|
return () => {
|
|
5470
6075
|
if (selectedImage) {
|
|
5471
6076
|
URL.revokeObjectURL(selectedImage);
|
|
5472
6077
|
}
|
|
5473
6078
|
};
|
|
5474
6079
|
}, [selectedImage]);
|
|
5475
|
-
(0,
|
|
6080
|
+
(0, import_react23.useEffect)(() => {
|
|
5476
6081
|
if (binaryRef.current) {
|
|
5477
6082
|
const isInsideTable2 = !!binaryRef.current.closest("table");
|
|
5478
6083
|
setIsInsideTable(isInsideTable2);
|
|
@@ -5492,28 +6097,47 @@ var binaryFieldController = (props) => {
|
|
|
5492
6097
|
};
|
|
5493
6098
|
// Annotate the CommonJS export names for ESM import in node:
|
|
5494
6099
|
0 && (module.exports = {
|
|
6100
|
+
API_APP_URL,
|
|
6101
|
+
API_PRESCHOOL_URL,
|
|
5495
6102
|
CloseIcon,
|
|
5496
6103
|
EyeIcon,
|
|
5497
6104
|
LoadingIcon,
|
|
6105
|
+
STORAGES,
|
|
5498
6106
|
binaryFieldController,
|
|
5499
6107
|
colorFieldController,
|
|
5500
|
-
|
|
6108
|
+
combineContexts,
|
|
6109
|
+
convertFieldsToArray,
|
|
5501
6110
|
copyLinkButtonController,
|
|
6111
|
+
countSum,
|
|
5502
6112
|
dateFieldController,
|
|
5503
6113
|
downLoadBinaryController,
|
|
5504
6114
|
downloadFileController,
|
|
5505
6115
|
durationController,
|
|
5506
6116
|
floatController,
|
|
5507
6117
|
floatTimeFiledController,
|
|
6118
|
+
getDateRange,
|
|
6119
|
+
languages,
|
|
5508
6120
|
many2manyFieldController,
|
|
5509
6121
|
many2manyTagsController,
|
|
5510
6122
|
many2oneButtonController,
|
|
5511
6123
|
many2oneFieldController,
|
|
6124
|
+
mergeButtons,
|
|
5512
6125
|
priorityFieldController,
|
|
6126
|
+
setStorageItemAsync,
|
|
5513
6127
|
statusDropdownController,
|
|
6128
|
+
useAuth,
|
|
6129
|
+
useCallAction,
|
|
5514
6130
|
useClickOutside,
|
|
6131
|
+
useConfig,
|
|
5515
6132
|
useDebounce,
|
|
5516
|
-
|
|
6133
|
+
useDetail,
|
|
6134
|
+
useGetRowIds,
|
|
6135
|
+
useListData,
|
|
6136
|
+
useMenu,
|
|
6137
|
+
useProfile,
|
|
6138
|
+
useStorageState,
|
|
6139
|
+
useUser,
|
|
6140
|
+
useViewV2
|
|
5517
6141
|
});
|
|
5518
6142
|
/*! Bundled license information:
|
|
5519
6143
|
|