tsv2-library 1.0.61-alpha.74 → 1.0.61-alpha.76
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.
|
@@ -19,7 +19,7 @@ interface TSFormContext<T> {
|
|
|
19
19
|
declare const useForm: <T>() => TSFormContext<T>;
|
|
20
20
|
declare const useField: <T>(path: MaybeRefOrGetter<string>, rules?: MaybeRef<RuleExpression<T>>, opts?: Partial<FieldOptions<T>> | undefined) => FieldContext<T>;
|
|
21
21
|
import Presets from './presets';
|
|
22
|
-
import { handleTokenExpiration, exportToExcel, formatGoDate, formatDate, getUserLocale, formatDateReadable, formatUserName, formatVowelSoundLabel, getImageURL, downloadFile, isObjectEmpty, useToast, listenSidebarChanges, unListenSidebarChanges, getCurrency, formatCurrency, getHostName, getBaseURL, useI18n, getNestedProperyValue, getSeverityByAssetStatus, clearStorage, forceLogout, reLogin, isValidJSONString, buildBodyParams, getTransactionRole, getSystemRole, hasSystemRole, hasTransactionRole, checkRouteAccess, hasApprovalRole, hasManagerRole, hasAnyManagerRole, hasMonitoringReportRole, hasAnyMonitoringReportRole, hasStaffRole } from './utils';
|
|
22
|
+
import { handleTokenExpiration, exportToExcel, formatGoDate, formatDate, getUserLocale, formatDateReadable, formatUserName, formatVowelSoundLabel, getImageURL, downloadFile, isObjectEmpty, useToast, listenSidebarChanges, unListenSidebarChanges, getCurrency, formatCurrency, getHostName, getBaseURL, useI18n, getNestedProperyValue, getSeverityByAssetStatus, clearStorage, forceLogout, reLogin, isValidJSONString, buildBodyParams, getTransactionRole, getSystemRole, hasSystemRole, hasTransactionRole, checkRouteAccess, hasApprovalRole, hasManagerRole, hasAnyManagerRole, hasMonitoringReportRole, hasAnyMonitoringReportRole, hasStaffRole, hasAccessToAssetDetail } from './utils';
|
|
23
23
|
import { flattenTreeNodeChildren, parseNodeKeys, filterNodeKeys } from './components/v2/Tree/helpers';
|
|
24
24
|
import useLoadingStore from './components/v2/Loading/store/loading.store';
|
|
25
25
|
import Tooltip from '../node_modules/primevue/tooltip';
|
|
@@ -31,4 +31,4 @@ declare const _default: {
|
|
|
31
31
|
install: (app: App) => void;
|
|
32
32
|
};
|
|
33
33
|
export default _default;
|
|
34
|
-
export { LibConfig, TSToastService, TSi18n, VueHtmlToPaper, Tooltip, Focus, DialogDamageLog, DialogMissingLog, DialogTransferLog, TSAssetInfo, TSApproverInfo, TSBadge, TSBadgeGroup, TSBreadcrumb, TSButton, TSButtonAddByScan, TSButtonBulkAction, TSButtonCopy, TSButtonDownload, TSButtonFilter, TSButtonLogHistory, TSButtonRadio, TSButtonViewLog, TSButtonScan, TSButtonSearch, TSButtonSearchByScan, TSButtonSelectTree, TSButtonSelectUser, TSButtonSync, TSButtonToggle, TSCalendar, TSCard, TSCarousel, TSCheckbox, TSCustomColumn, TSDatePicker, TSDataTable, TSDayPicker, TSDialog, TSDialogApprovalList, TSDialogAssetNameDetail, TSDialogConfirm, TSDialogForm, TSDialogLinkedAsset, TSDialogPrintQR, TSDialogReportDamage, TSDialogReportMissing, TSDialogReportTag, TSDialogSelectTree, TSDialogSelectAsset, TSDialogSelectUser, TSDisposalReport, TSDropdown, TSFilterContainer, TSFileUpload, TSForm, TSIcon, TSImage, TSImageCompressor, TSInlineMessage, TSInputBadge, TSInputCurrency, TSInputEmail, TSInputNumber, TSInputOTP, TSInputPassword, TSInputPhoneNumber, TSInputRangeNumber, TSInputText, TSInputSearch, TSInputURL, TSLoading, TSMenu, TSMultiSelect, TSOverlayPanel, TSPaginator, TSProgressBar, TSSteps, TSTabMenu, TSTagType, TSTextarea, TSTimeline, TSToast, TSTransactionRoles, TSTree, TSTreeSearchInput, TSUserWithIcon, TSValidatorMessage, handleTokenExpiration, exportToExcel, formatGoDate, formatDate, getUserLocale, formatDateReadable, formatUserName, formatVowelSoundLabel, getImageURL, downloadFile, isObjectEmpty, useToast, listenSidebarChanges, unListenSidebarChanges, getCurrency, formatCurrency, getHostName, getBaseURL, useI18n, useForm, useField, getNestedProperyValue, getSeverityByAssetStatus, clearStorage, forceLogout, reLogin, isValidJSONString, buildBodyParams, getTransactionRole, getSystemRole, hasSystemRole, hasTransactionRole, checkRouteAccess, hasApprovalRole, hasManagerRole, hasAnyManagerRole, hasMonitoringReportRole, hasAnyMonitoringReportRole, hasStaffRole, flattenTreeNodeChildren, parseNodeKeys, filterNodeKeys, TreeAPI, RoutineAPI, DisposalAPI, RoutineServices, AssetsServices, AssetNameService, AssetBrandService, DisposalServices, FilterMatchMode, useLoadingStore, Presets, };
|
|
34
|
+
export { LibConfig, TSToastService, TSi18n, VueHtmlToPaper, Tooltip, Focus, DialogDamageLog, DialogMissingLog, DialogTransferLog, TSAssetInfo, TSApproverInfo, TSBadge, TSBadgeGroup, TSBreadcrumb, TSButton, TSButtonAddByScan, TSButtonBulkAction, TSButtonCopy, TSButtonDownload, TSButtonFilter, TSButtonLogHistory, TSButtonRadio, TSButtonViewLog, TSButtonScan, TSButtonSearch, TSButtonSearchByScan, TSButtonSelectTree, TSButtonSelectUser, TSButtonSync, TSButtonToggle, TSCalendar, TSCard, TSCarousel, TSCheckbox, TSCustomColumn, TSDatePicker, TSDataTable, TSDayPicker, TSDialog, TSDialogApprovalList, TSDialogAssetNameDetail, TSDialogConfirm, TSDialogForm, TSDialogLinkedAsset, TSDialogPrintQR, TSDialogReportDamage, TSDialogReportMissing, TSDialogReportTag, TSDialogSelectTree, TSDialogSelectAsset, TSDialogSelectUser, TSDisposalReport, TSDropdown, TSFilterContainer, TSFileUpload, TSForm, TSIcon, TSImage, TSImageCompressor, TSInlineMessage, TSInputBadge, TSInputCurrency, TSInputEmail, TSInputNumber, TSInputOTP, TSInputPassword, TSInputPhoneNumber, TSInputRangeNumber, TSInputText, TSInputSearch, TSInputURL, TSLoading, TSMenu, TSMultiSelect, TSOverlayPanel, TSPaginator, TSProgressBar, TSSteps, TSTabMenu, TSTagType, TSTextarea, TSTimeline, TSToast, TSTransactionRoles, TSTree, TSTreeSearchInput, TSUserWithIcon, TSValidatorMessage, handleTokenExpiration, exportToExcel, formatGoDate, formatDate, getUserLocale, formatDateReadable, formatUserName, formatVowelSoundLabel, getImageURL, downloadFile, isObjectEmpty, useToast, listenSidebarChanges, unListenSidebarChanges, getCurrency, formatCurrency, getHostName, getBaseURL, useI18n, useForm, useField, getNestedProperyValue, getSeverityByAssetStatus, clearStorage, forceLogout, reLogin, isValidJSONString, buildBodyParams, getTransactionRole, getSystemRole, hasSystemRole, hasTransactionRole, checkRouteAccess, hasApprovalRole, hasManagerRole, hasAnyManagerRole, hasMonitoringReportRole, hasAnyMonitoringReportRole, hasStaffRole, hasAccessToAssetDetail, flattenTreeNodeChildren, parseNodeKeys, filterNodeKeys, TreeAPI, RoutineAPI, DisposalAPI, RoutineServices, AssetsServices, AssetNameService, AssetBrandService, DisposalServices, FilterMatchMode, useLoadingStore, Presets, };
|
|
@@ -4,7 +4,7 @@ import exportToExcel from './exportToExcel.util';
|
|
|
4
4
|
import { formatGoDate, formatDate, formatDateReadable, getUserLocale } from './date.util';
|
|
5
5
|
import useToast from './toast.util';
|
|
6
6
|
import { getImageURL, downloadFile } from './getImageURL.util';
|
|
7
|
-
import { getTransactionRole, getSystemRole, hasSystemRole, hasTransactionRole, checkRouteAccess, hasApprovalRole, hasManagerRole, hasAnyManagerRole, hasAnyMonitoringReportRole, hasMonitoringReportRole, hasStaffRole } from './role.util';
|
|
7
|
+
import { getTransactionRole, getSystemRole, hasSystemRole, hasTransactionRole, checkRouteAccess, hasApprovalRole, hasManagerRole, hasAnyManagerRole, hasAnyMonitoringReportRole, hasMonitoringReportRole, hasStaffRole, hasAccessToAssetDetail } from './role.util';
|
|
8
8
|
import { getCurrency, formatCurrency } from './currency.util';
|
|
9
9
|
import { unListenSidebarChanges, listenSidebarChanges } from './listenSidebarChanges.util';
|
|
10
10
|
import { getBaseURL, getHostName } from './getBaseURL.util';
|
|
@@ -17,4 +17,4 @@ import { isValidJSONString } from './json.util';
|
|
|
17
17
|
import { buildBodyParams } from './request.util';
|
|
18
18
|
declare const isObjectEmpty: (object: object) => boolean;
|
|
19
19
|
declare const getNestedProperyValue: (object: object, property: string) => string | boolean | number | object;
|
|
20
|
-
export { isObjectEmpty, getNestedProperyValue, handleTokenExpiration, getImageURL, downloadFile, formatUserName, formatVowelSoundLabel, exportToExcel, formatGoDate, formatDate, getUserLocale, formatDateReadable, useToast, listenSidebarChanges, unListenSidebarChanges, getCurrency, formatCurrency, getBaseURL, getHostName, useI18n, getSeverityByAssetStatus, clearStorage, forceLogout, reLogin, isValidJSONString, buildBodyParams, getTransactionRole, getSystemRole, hasSystemRole, hasTransactionRole, checkRouteAccess, hasApprovalRole, hasManagerRole, hasAnyManagerRole, hasMonitoringReportRole, hasAnyMonitoringReportRole, hasStaffRole, };
|
|
20
|
+
export { isObjectEmpty, getNestedProperyValue, handleTokenExpiration, getImageURL, downloadFile, formatUserName, formatVowelSoundLabel, exportToExcel, formatGoDate, formatDate, getUserLocale, formatDateReadable, useToast, listenSidebarChanges, unListenSidebarChanges, getCurrency, formatCurrency, getBaseURL, getHostName, useI18n, getSeverityByAssetStatus, clearStorage, forceLogout, reLogin, isValidJSONString, buildBodyParams, getTransactionRole, getSystemRole, hasSystemRole, hasTransactionRole, checkRouteAccess, hasApprovalRole, hasManagerRole, hasAnyManagerRole, hasMonitoringReportRole, hasAnyMonitoringReportRole, hasStaffRole, hasAccessToAssetDetail, };
|
|
@@ -28,5 +28,23 @@ declare const hasAnyMonitoringReportRole: () => boolean;
|
|
|
28
28
|
declare const hasStaffRole: (name: TransactionAttribute) => boolean;
|
|
29
29
|
declare const hasMonitoringReportRole: (name: TransactionAttribute) => boolean;
|
|
30
30
|
declare const hasApprovalRole: (name: TransactionAttribute) => boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Vue Router navigation guard that checks user access based on the route's metadata
|
|
33
|
+
* and the user's type retrieved from local storage.
|
|
34
|
+
*
|
|
35
|
+
* Access is granted if:
|
|
36
|
+
* 1. The user is currently logging out (flag checked by `checkAndClearLogoutFlag`).
|
|
37
|
+
* 2. The route's `meta.hasAccess` is true AND the user is an 'Admin'.
|
|
38
|
+
* 3. The route's `meta.hasAccess` is true AND the route is a special exemption path
|
|
39
|
+
* ('handover-confirmation' or 'my-profile').
|
|
40
|
+
*
|
|
41
|
+
* If access is denied, navigation is redirected to '/not-found'.
|
|
42
|
+
*
|
|
43
|
+
* @param {RouteLocationNormalized} to - The target route location object.
|
|
44
|
+
* @param {RouteLocationNormalized} from - The current route location object.
|
|
45
|
+
* @param {NavigationGuardNext} next - The function to call to resolve the hook.
|
|
46
|
+
* @returns {void}
|
|
47
|
+
*/
|
|
31
48
|
declare const checkRouteAccess: (to: RouteLocationNormalized, from: RouteLocationNormalized, next: NavigationGuardNext) => void;
|
|
32
|
-
|
|
49
|
+
declare const hasAccessToAssetDetail: () => boolean;
|
|
50
|
+
export { getTransactionRole, getSystemRole, hasTransactionRole, hasApprovalRole, hasSystemRole, checkRouteAccess, hasManagerRole, hasAnyManagerRole, hasMonitoringReportRole, hasAnyMonitoringReportRole, hasStaffRole, hasAccessToAssetDetail, };
|
package/dist/tsv2-library.es.js
CHANGED
|
@@ -19735,22 +19735,54 @@ const hasApprovalRole = (name) => {
|
|
|
19735
19735
|
const { approver } = getTransactionRole(name);
|
|
19736
19736
|
return approver;
|
|
19737
19737
|
};
|
|
19738
|
+
const checkAndClearLogoutFlag = () => {
|
|
19739
|
+
const loggingOut = sessionStorage.getItem("logout") === "true";
|
|
19740
|
+
if (loggingOut) {
|
|
19741
|
+
sessionStorage.removeItem("logout");
|
|
19742
|
+
}
|
|
19743
|
+
return loggingOut;
|
|
19744
|
+
};
|
|
19738
19745
|
const checkRouteAccess = (to, from, next) => {
|
|
19746
|
+
const isLoggingOut = checkAndClearLogoutFlag();
|
|
19747
|
+
if (isLoggingOut) {
|
|
19748
|
+
return next();
|
|
19749
|
+
}
|
|
19739
19750
|
const { userType } = JSON.parse(
|
|
19740
19751
|
localStorage.getItem("user") ?? "{}"
|
|
19741
19752
|
);
|
|
19742
19753
|
const { hasAccess } = to.meta;
|
|
19743
19754
|
const isAdmin = userType === "Admin";
|
|
19744
|
-
const
|
|
19745
|
-
const
|
|
19746
|
-
|
|
19747
|
-
|
|
19748
|
-
console.log("👽 ~ checkRouteAccess:", to);
|
|
19749
|
-
if (userHasAccess || loggingOut)
|
|
19755
|
+
const isSpecialExemptionRoute = to.path.includes("handover-confirmation") || to.path.includes("my-profile");
|
|
19756
|
+
const userHasAccess = hasAccess && (isAdmin || isSpecialExemptionRoute);
|
|
19757
|
+
console.log("👽:", to);
|
|
19758
|
+
if (userHasAccess)
|
|
19750
19759
|
next();
|
|
19751
19760
|
else
|
|
19752
19761
|
navigateToUrl("/not-found");
|
|
19753
19762
|
};
|
|
19763
|
+
const hasAccessToAssetDetail = () => {
|
|
19764
|
+
const systemRoles = [
|
|
19765
|
+
"depreciationGroup",
|
|
19766
|
+
"depreciationMethod",
|
|
19767
|
+
"purchaseDocument",
|
|
19768
|
+
"purchaseInformation",
|
|
19769
|
+
"tag",
|
|
19770
|
+
"registerAsset"
|
|
19771
|
+
];
|
|
19772
|
+
const managerRoles = [
|
|
19773
|
+
"auditRole",
|
|
19774
|
+
"maintenanceRole",
|
|
19775
|
+
"borrowingRole",
|
|
19776
|
+
"disposalRole",
|
|
19777
|
+
"transferRole",
|
|
19778
|
+
"trackingRole",
|
|
19779
|
+
"repairRole"
|
|
19780
|
+
];
|
|
19781
|
+
const hasSystemAccess = systemRoles.some((role) => hasSystemRole(role));
|
|
19782
|
+
const hasManagerAccess = managerRoles.some((role) => hasManagerRole(role));
|
|
19783
|
+
const hasStaffAccess = hasStaffRole("repairRole");
|
|
19784
|
+
return hasSystemAccess || hasManagerAccess || hasStaffAccess;
|
|
19785
|
+
};
|
|
19754
19786
|
const currencies = [
|
|
19755
19787
|
{
|
|
19756
19788
|
label: "؋ - Afghan Afghani",
|
|
@@ -28028,7 +28060,7 @@ const _sfc_main$1r = /* @__PURE__ */ defineComponent({
|
|
|
28028
28060
|
else
|
|
28029
28061
|
asset.value = props.transactionDetail;
|
|
28030
28062
|
});
|
|
28031
|
-
|
|
28063
|
+
JSON.parse(localStorage.getItem("user") ?? "{}");
|
|
28032
28064
|
const asset = ref();
|
|
28033
28065
|
const useStatusField = computed(() => {
|
|
28034
28066
|
var _a;
|
|
@@ -28146,7 +28178,7 @@ const _sfc_main$1r = /* @__PURE__ */ defineComponent({
|
|
|
28146
28178
|
createElementVNode("div", _hoisted_3$D, [
|
|
28147
28179
|
createElementVNode("div", _hoisted_4$q, [
|
|
28148
28180
|
createElementVNode("div", _hoisted_5$j, toDisplayString$1(nameWithSequence.value), 1),
|
|
28149
|
-
unref(
|
|
28181
|
+
unref(hasAccessToAssetDetail)() ? (openBlock(), createElementBlock("a", {
|
|
28150
28182
|
key: 0,
|
|
28151
28183
|
href: `/assets/detail/${((_a = asset.value) == null ? void 0 : _a.asset) ?? ((_b = asset.value) == null ? void 0 : _b._id)}`,
|
|
28152
28184
|
class: "text-primary-500",
|
|
@@ -74090,6 +74122,7 @@ export {
|
|
|
74090
74122
|
getTransactionRole,
|
|
74091
74123
|
getUserLocale,
|
|
74092
74124
|
handleTokenExpiration,
|
|
74125
|
+
hasAccessToAssetDetail,
|
|
74093
74126
|
hasAnyManagerRole,
|
|
74094
74127
|
hasAnyMonitoringReportRole,
|
|
74095
74128
|
hasApprovalRole,
|