From 5167b1242439bf397aa6ce219c71845dbc603828 Mon Sep 17 00:00:00 2001 From: lucile varloteaux <lucile.varloteaux@inrae.fr> Date: Wed, 27 Nov 2024 14:31:09 +0100 Subject: [PATCH 1/4] save avant merge --- .../DetailApplicationModalCard.vue | 6 +- src/components/common/CollapsibleTree.vue | 24 +++---- src/composable/applications/applications.js | 1 - src/model/ApplicationResult.js | 5 +- src/model/User.js | 14 ++-- src/services/TagService.js | 5 +- .../AdditionalFileInfosView.vue | 6 +- src/views/application/ApplicationInfoView.vue | 66 +++++++++---------- src/views/application/ApplicationsView.vue | 51 +++++++++++--- .../AuthorizationsRightsRequestInfoView.vue | 6 +- .../DataTypeAuthorizationsView.vue | 13 ++-- src/views/data/DataTableView.vue | 2 +- 12 files changed, 110 insertions(+), 89 deletions(-) diff --git a/src/components/application/DetailApplicationModalCard.vue b/src/components/application/DetailApplicationModalCard.vue index feb50e86e..2efe4923b 100644 --- a/src/components/application/DetailApplicationModalCard.vue +++ b/src/components/application/DetailApplicationModalCard.vue @@ -73,11 +73,9 @@ export default { }); const validated = computed({ get() { - let charteTimeStamp = User.STORED_AUTHENTICATED_USER()?.chartes?.[props.application.id] + let charteTimeStamp = User.STORED_AUTHENTICATED_USER()?.chartes?.[props.application.id]; if (charteTimeStamp) { - return ( - new Date().getTime() > charteTimeStamp - ); + return new Date().getTime() > charteTimeStamp; } return false; }, diff --git a/src/components/common/CollapsibleTree.vue b/src/components/common/CollapsibleTree.vue index 988510538..cf8a9ff4e 100644 --- a/src/components/common/CollapsibleTree.vue +++ b/src/components/common/CollapsibleTree.vue @@ -227,28 +227,28 @@ export default { computed: { length() { return length; - } + }, }, components: { TagsInfos, LoadingAnimate, FontAwesomeIcon, AvailiblityChart }, props: { applicationName: String, canUpload: { type: Boolean, - default: true + default: true, }, option: Object, level: { type: Number, - default: 0 + default: 0, }, showEmpty: { value: { type: Boolean, - default: false - } + default: false, + }, }, tags: { - type: Object + type: Object, }, referenceSynthesis: Array, onClickLabelCb: Function, @@ -257,20 +257,20 @@ export default { buttons: Array, withRadios: { type: Boolean, - default: false + default: false, }, radioName: Object, repository: Object, repositoryRedirect: Function, lineCount: { type: Number, - default: 0 + default: 0, }, isLoading: Boolean, isUploading: Boolean, applicationTitle: { - type: String - } + type: String, + }, }, setup(props) { let innerOptionChecked = null; @@ -299,9 +299,9 @@ export default { displayChildren, refFile, innerOptionChecked, - updateCountLineFile + updateCountLineFile, }; - } + }, }; </script> diff --git a/src/composable/applications/applications.js b/src/composable/applications/applications.js index d6fa4ab7e..2e411b5af 100644 --- a/src/composable/applications/applications.js +++ b/src/composable/applications/applications.js @@ -18,7 +18,6 @@ function addApplication(result) { .map((a, i) => (a.name === application.name ? i : -1)) .find((i) => i >= 0); let localApplication = applications.value; - console.log("localApplication", localApplication); if (id >= 0) { localApplication[id] = application; } else { diff --git a/src/model/ApplicationResult.js b/src/model/ApplicationResult.js index 73777bae5..5ca75a9c6 100644 --- a/src/model/ApplicationResult.js +++ b/src/model/ApplicationResult.js @@ -89,9 +89,8 @@ export class ApplicationResult { this.dependantNodesByDataName = application.dependantNodesByDataName; this.orderedReferences = application.orderedReferences; this.referenceSynthesis = application.referenceSynthesis; - let charteTimeStamp = User.STORED_AUTHENTICATED_USER()?.chartes?.[application.id] - this.hasSignedLastCharte = - new Date().getTime() > charteTimeStamp; + let charteTimeStamp = User.STORED_AUTHENTICATED_USER()?.chartes?.[application.id]; + this.hasSignedLastCharte = new Date().getTime() > charteTimeStamp; this.hasSignedCharte = charteTimeStamp; } } diff --git a/src/model/User.js b/src/model/User.js index 7bf13dcf3..f4d9e545b 100644 --- a/src/model/User.js +++ b/src/model/User.js @@ -1,10 +1,10 @@ export class User { static states = { idle: false, active: true, pending: false, closed: false }; static INSTANCE = new User(); - static STORED_AUTHENTICATED_USER = function() { - let authenticatedUser = localStorage.getItem('authenticatedUser'); - return authenticatedUser?JSON.parse(authenticatedUser):{}; - } + static STORED_AUTHENTICATED_USER = function () { + let authenticatedUser = localStorage.getItem("authenticatedUser"); + return authenticatedUser ? JSON.parse(authenticatedUser) : {}; + }; id = ""; login = ""; @@ -26,9 +26,9 @@ export class User { lang = navigator.language.slice(0, 2) || "fr"; constructor(userData) { - if (!userData ) { - let user = localStorage.getItem('authenticatedUser'); - user = user?JSON.parse(user):{}; + if (!userData) { + let user = localStorage.getItem("authenticatedUser"); + user = user ? JSON.parse(user) : {}; if (!user) { return; } diff --git a/src/services/TagService.js b/src/services/TagService.js index deaaa608b..e3294b3eb 100644 --- a/src/services/TagService.js +++ b/src/services/TagService.js @@ -45,10 +45,7 @@ export class TagService extends Fetcher { ) { return true; } else { - return selectedTags.some( - (selectedTag) => - selectedTag.tagName === tag.tagName - ); + return selectedTags.some((selectedTag) => selectedTag.tagName === tag.tagName); } } }); diff --git a/src/views/additionalfiles/AdditionalFileInfosView.vue b/src/views/additionalfiles/AdditionalFileInfosView.vue index ecb4ee050..84b185620 100644 --- a/src/views/additionalfiles/AdditionalFileInfosView.vue +++ b/src/views/additionalfiles/AdditionalFileInfosView.vue @@ -477,8 +477,7 @@ export default class AdditionalFileInfosView extends Vue { this.validFile = true; this.forApplication = additionalFile.forApplication; this.currentUser = additionalFiles.users.find( - (user) => - user.id == (additionalFile.user || User.STORED_AUTHENTICATED_USER()?.id) + (user) => user.id == (additionalFile.user || User.STORED_AUTHENTICATED_USER()?.id) ); this.comment = additionalFile.comment; this.fields = Object.keys(this.format || {} || []).reduce((acc, field) => { @@ -507,8 +506,7 @@ export default class AdditionalFileInfosView extends Vue { this.canManage = this.isApplicationAdmin || (authorizations.users && - authorizations.users[0].login === - User.STORED_AUTHENTICATED_USER()?.login); + authorizations.users[0].login === User.STORED_AUTHENTICATED_USER()?.login); } else { this.fileNames = additionalFiles.fileNames; let initialValue = new Authorizations( diff --git a/src/views/application/ApplicationInfoView.vue b/src/views/application/ApplicationInfoView.vue index 1e194a7a0..4d93a3baf 100644 --- a/src/views/application/ApplicationInfoView.vue +++ b/src/views/application/ApplicationInfoView.vue @@ -21,8 +21,8 @@ export default { emits: ["setValidatedCharte"], props: { applicationName: { - type: String - } + type: String, + }, }, setup(props, ctx) { const isCardModalActive = useBoolean().refBoolean; @@ -30,7 +30,7 @@ export default { const redirection = ref(() => { app.$router.push(`/applications/${props.applicationName}`); }); - const showCharte = function(objectShowCharte) { + const showCharte = function (objectShowCharte) { if (!objectShowCharte) { return; } else { @@ -43,25 +43,23 @@ export default { get() { let chartestimeStamp = User.STORED_AUTHENTICATED_USER()?.chartes?.[props.application.id]; if (chartestimeStamp) { - return ( - new Date().getTime() > chartestimeStamp - ); + return new Date().getTime() > chartestimeStamp; } return false; }, set(bool) { bool && - services.loginService.modifAcount({ - login: User.STORED_AUTHENTICATED_USER()?.login, - email: User.STORED_AUTHENTICATED_USER()?.email, - charte: props.application.id - }); + services.loginService.modifAcount({ + login: User.STORED_AUTHENTICATED_USER()?.login, + email: User.STORED_AUTHENTICATED_USER()?.email, + charte: props.application.id, + }); bool && - ctx.emit("setValidatedCharte", { - applicationId: application.id, - validated: bool - }); - } + ctx.emit("setValidatedCharte", { + applicationId: application.id, + validated: bool, + }); + }, }); const { reactiveObject: application, doChangeObject: changeApplication } = useObject( new ApplicationResult() @@ -89,7 +87,7 @@ export default { showAdditionalFilesManagementRights, requestRights, authorizationsManagementForApplicationUsers, - showRequestRights + showRequestRights, } = useRedirections(application); onMounted(async () => { @@ -99,7 +97,7 @@ export default { "Accueil", () => app.$router.push(`/applications/${props.applicationName}`), () => app.$router.push(`/applications`) - ) + ), ]); }); @@ -111,7 +109,7 @@ export default { "DATATYPE", "CONFIGURATION", "REFERENCETYPE", - "ADDITIONALFILE" + "ADDITIONALFILE", ]) ) ); @@ -120,12 +118,12 @@ export default { localRefName: services.internationalisationService.localeReferenceNames( props.applicationName, application - ) + ), }); } catch (e) { services.alertService.toastError( i18n.t("alert.server-error-appli-no-exist", { - name: props.applicationName + name: props.applicationName, }) ); } @@ -175,9 +173,9 @@ export default { canManagerUser, canManagerApplication, url, - redirection + redirection, }; - } + }, }; </script> @@ -267,7 +265,7 @@ export default { icon-left="drafting-compass" type="is-primary" @click="showCharte(displayReferencesManagement(application))" - >{{ $t("applications.references") }} + >{{ $t("applications.references") }} </b-button> </div> <div @@ -279,7 +277,7 @@ export default { icon-left="poll" type="is-primary" @click="showCharte(displayDataSetManagement(application))" - >{{ $t("applications.dataset") }} + >{{ $t("applications.dataset") }} </b-button> </div> </div> @@ -289,7 +287,7 @@ export default { outlined type="is-warning" @click="showDataRights(application)" - >{{ $t("applications.functions.datas-rights") }} + >{{ $t("applications.functions.datas-rights") }} </b-button> </div> </b-tab-item> @@ -302,8 +300,8 @@ export default { > <template #header> <span class="rubriqueTitle">{{ - $t("applications.functions.additional-files-manage") - }}</span> + $t("applications.functions.additional-files-manage") + }}</span> </template> <div class="buttonWarper"> <b-button @@ -329,8 +327,8 @@ export default { > <template #header> <span class="rubriqueTitle">{{ - $t("applications.functions.application-manage") - }}</span> + $t("applications.functions.application-manage") + }}</span> </template> <div class="buttonWarper columns"> <b-button @@ -401,8 +399,8 @@ export default { <b-tab-item aria-description="authorization"> <template #header> <span class="rubriqueTitle">{{ - $t("applications.functions.right-requests-manage") - }}</span> + $t("applications.functions.right-requests-manage") + }}</span> </template> <div class="buttonWarper"> <b-button @@ -436,7 +434,7 @@ export default { icon-left="drafting-compass" type="is-primary" @click="showCharte(displayReferencesManagement(application))" - >{{ $t("applications.references") }} + >{{ $t("applications.references") }} </b-button> </div> <div @@ -448,7 +446,7 @@ export default { icon-left="poll" type="is-primary" @click="showCharte(displayDataSetManagement(application))" - >{{ $t("applications.dataset") }} + >{{ $t("applications.dataset") }} </b-button> </div> <div diff --git a/src/views/application/ApplicationsView.vue b/src/views/application/ApplicationsView.vue index c89943fa9..76f0430a6 100644 --- a/src/views/application/ApplicationsView.vue +++ b/src/views/application/ApplicationsView.vue @@ -40,7 +40,6 @@ false-value="false" field="name" true-value="true" - @input="alphabeticalSort = ''" >{{ $t("applications.trierRecent") }} </b-checkbox> </b-field> @@ -171,25 +170,61 @@ export default { const selected = useBoolean().refBoolean; const alphabeticalSort = useText().refText; const selectedApplications = computed(() => { - let sa = applications && applications.value; + let applicationsListOrderOrFilter = applications.value; if (filterName.value.length > 2) - sa = sa.filter( + applicationsListOrderOrFilter = applicationsListOrderOrFilter.filter( (a) => a.localName.toString().toLowerCase().indexOf(filterName.value.toLowerCase()) >= 0 ); - if (checkboxDate.value === "true") sa = sa.sort((a, b) => b.creationDate - a.creationDate); - else sa = sa.sort((a, b) => b.creationDate - a.creationDate).reverse(); + applicationsListOrderOrFilter = sortedApplicationsListForDate(applicationsListOrderOrFilter); if (alphabeticalSort.value === "Az") { - sa = sa.sort((a, b) => a.localName.localeCompare(b.localName)); + applicationsListOrderOrFilter = applicationsListOrderOrFilter.sort((a, b) => + a.localName.localeCompare(b.localName) + ); } else if (alphabeticalSort.value === "Za") { - sa = sa.sort((a, b) => a.localName.localeCompare(b.localName)).reverse(); + applicationsListOrderOrFilter = applicationsListOrderOrFilter + .sort((a, b) => a.localName.localeCompare(b.localName)) + .reverse(); } - return sa; + return applicationsListOrderOrFilter; }); onMounted(async () => { loadApplications(["DATATYPE", "REFERENCETYPE", "CONFIGURATION", "ADDITIONALFILE"]); }); + function sortedApplicationsListForDate(localApplications) { + let apps = applications.value || applications; + localApplications = apps.sort((a, b) => { + const localA = new Date( + a.updateDate[0], + a.updateDate[1] - 1, + a.updateDate[2], + a.updateDate[3], + a.updateDate[4], + a.updateDate[5], + a.updateDate[6] / 1000000 + ); + const localB = new Date( + b.updateDate[0], + b.updateDate[1] - 1, + b.updateDate[2], + b.updateDate[3], + b.updateDate[4], + b.updateDate[5], + b.updateDate[6] / 1000000 + ); + return checkboxDate.value + ? localB.getTime() - localA.getTime() + : localA.getTime() - localB.getTime(); + }); + console.log( + "applicationsListOrderOrFilter in computed", + checkboxDate.value, + localApplications + ); + return localApplications; + } + const ownApplications = computed(() => { return applications.value.filter((application) => application.isApplicationUser()); }); diff --git a/src/views/authorizations/AuthorizationsRightsRequestInfoView.vue b/src/views/authorizations/AuthorizationsRightsRequestInfoView.vue index 3a8141401..b7717db6f 100644 --- a/src/views/authorizations/AuthorizationsRightsRequestInfoView.vue +++ b/src/views/authorizations/AuthorizationsRightsRequestInfoView.vue @@ -534,10 +534,8 @@ export default { let usersId; let authenticatedUserId = User.STORED_AUTHENTICATED_USER().id; if ( - (currentUser.value.id && - currentUser.value.id !== authenticatedUserId) || - (currentUser.value[0] && - currentUser.value[0].id !== authenticatedUserId) + (currentUser.value.id && currentUser.value.id !== authenticatedUserId) || + (currentUser.value[0] && currentUser.value[0].id !== authenticatedUserId) ) { usersId = currentUser.value.id ? [currentUser.value.id, authenticatedUserId] diff --git a/src/views/authorizations/DataTypeAuthorizationsView.vue b/src/views/authorizations/DataTypeAuthorizationsView.vue index 11da1e277..a92819727 100644 --- a/src/views/authorizations/DataTypeAuthorizationsView.vue +++ b/src/views/authorizations/DataTypeAuthorizationsView.vue @@ -86,8 +86,7 @@ {{ $t("dataTypeAuthorizations.table-auth-users-all-user") }} </b-radio> </div> - <div class="column is-offset-4 is-2" - v-if="isApplicationManager"> + <div class="column is-offset-4 is-2" v-if="isApplicationManager"> <b-button icon-left="plus" outlined @@ -229,7 +228,7 @@ > <b-checkbox v-model="checkbox[auth.name + '_' + props.row.name]" - :disabled="(isApplicationManager || isUserManager)" + :disabled="isApplicationManager || isUserManager" @input="updateListUsersInAuthorization(auth, props.row.name, $event)" > {{ auth.name }} @@ -454,8 +453,9 @@ <b-checkbox v-model="checkbox[props.row.name + '_' + user.label]" :disabled=" - ((props?.row?.users || []).map((use) => use.login).length === 1 && - checkbox[props.row.name + '_' + user.label] === true) && (isApplicationManager || isUserManager) + (props?.row?.users || []).map((use) => use.login).length === 1 && + checkbox[props.row.name + '_' + user.label] === true && + (isApplicationManager || isUserManager) " @input="updateListUsersInAuthorization(props.row, user.label, $event)" > @@ -591,8 +591,7 @@ export default { const { shallowRefArray: authorizations, doChangeArray: changeAuthorizations } = useArray(); const { refBoolean: isApplicationManager, doChangeBoolean: changeIsApplicationManager } = useBoolean(false); - const { refBoolean: isUserManager, doChangeBoolean: changeIsUserManager } = - useBoolean(false); + const { refBoolean: isUserManager, doChangeBoolean: changeIsUserManager } = useBoolean(false); const { refBoolean: isDragging } = useBoolean(false); const { refBoolean: isCardModalActive } = useBoolean(false); const { refBoolean: hasAuthorizationsByUsers } = useBoolean(false); diff --git a/src/views/data/DataTableView.vue b/src/views/data/DataTableView.vue index cfe0c6242..21775ac48 100644 --- a/src/views/data/DataTableView.vue +++ b/src/views/data/DataTableView.vue @@ -593,7 +593,7 @@ export default { const ONE = Component.MULTIPLICITY_ONE; async function showModal() { - console.log()("coucu"); + console.log("coucou"); } return { -- GitLab From e10b1db25a16e1d57a7e03a573082ac91da377a2 Mon Sep 17 00:00:00 2001 From: lucile varloteaux <lucile.varloteaux@inrae.fr> Date: Wed, 27 Nov 2024 16:38:55 +0100 Subject: [PATCH 2/4] =?UTF-8?q?r=C3=A9paration=20filtre=20et=20ordre=20de?= =?UTF-8?q?=20la=20liste=20des=20applications?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/locales/en.json | 1 + src/locales/fr.json | 1 + src/views/application/ApplicationsView.vue | 77 ++++++++++++---------- 3 files changed, 44 insertions(+), 35 deletions(-) diff --git a/src/locales/en.json b/src/locales/en.json index bcab112ce..fa5ab6d88 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -154,6 +154,7 @@ "trier": "Sort by", "trierA_z": "Name A - z", "trierRecent": "Recent date", + "trierAncien": "Old date", "trierZ_a": "Name Z - a", "version": "The current version of the application <b class=\"has-text-primary\">{applicationName}</b> is <b class=\"has-text-primary\">{version}.</b>" }, diff --git a/src/locales/fr.json b/src/locales/fr.json index 572e46eb4..437e417a6 100644 --- a/src/locales/fr.json +++ b/src/locales/fr.json @@ -153,6 +153,7 @@ "trier": "Trier", "trierA_z": "Nom A - z", "trierRecent": "Date récente", + "trierAncien": "Date ancienne", "trierZ_a": "Nom Z - a", "version": "La version actuelle de l'application <b class=\"has-text-primary\">{applicationName}</b> est la version <b class=\"has-text-primary\">{version}.</b>" }, diff --git a/src/views/application/ApplicationsView.vue b/src/views/application/ApplicationsView.vue index 76f0430a6..06916e892 100644 --- a/src/views/application/ApplicationsView.vue +++ b/src/views/application/ApplicationsView.vue @@ -34,31 +34,39 @@ <div class="card-content"> <div class="content"> <b-field class="columns"> - <b-checkbox - v-model="checkboxDate" - class="column" - false-value="false" - field="name" - true-value="true" - >{{ $t("applications.trierRecent") }} - </b-checkbox> + <b-radio + v-model="alphabeticalOrDateSort" + name="DateSort" + native-value="0_9" + @input="sortedApplicationsListForDate(applications, $event)" + > + {{ $t("applications.trierRecent") }} + </b-radio> + <b-radio + v-model="alphabeticalOrDateSort" + name="DateSort" + native-value="9_0" + @input="sortedApplicationsListForDate(applications, $event)" + > + {{ $t("applications.trierAncien") }} + </b-radio> </b-field> </div> <div class="content"> <b-field class="columns"> <b-radio - v-model="alphabeticalSort" - name="alphabeticalSort" + v-model="alphabeticalOrDateSort" + name="alphabeticalOrDateSort" native-value="Az" - @input="checkboxDate = false" + @input="sortedApplicationsListForName(applications, $event)" > {{ $t("applications.trierA_z") }} </b-radio> <b-radio - v-model="alphabeticalSort" - name="alphabeticalSort" + v-model="alphabeticalOrDateSort" + name="alphabeticalOrDateSort" native-value="Za" - @input="checkboxDate = false" + @input="sortedApplicationsListForName(applications, $event)" > {{ $t("applications.trierZ_a") }} </b-radio> @@ -168,23 +176,13 @@ export default { // filtre variable const filterName = useText().refText; const selected = useBoolean().refBoolean; - const alphabeticalSort = useText().refText; + const alphabeticalOrDateSort = useText().refText; const selectedApplications = computed(() => { let applicationsListOrderOrFilter = applications.value; if (filterName.value.length > 2) applicationsListOrderOrFilter = applicationsListOrderOrFilter.filter( (a) => a.localName.toString().toLowerCase().indexOf(filterName.value.toLowerCase()) >= 0 ); - applicationsListOrderOrFilter = sortedApplicationsListForDate(applicationsListOrderOrFilter); - if (alphabeticalSort.value === "Az") { - applicationsListOrderOrFilter = applicationsListOrderOrFilter.sort((a, b) => - a.localName.localeCompare(b.localName) - ); - } else if (alphabeticalSort.value === "Za") { - applicationsListOrderOrFilter = applicationsListOrderOrFilter - .sort((a, b) => a.localName.localeCompare(b.localName)) - .reverse(); - } return applicationsListOrderOrFilter; }); @@ -192,9 +190,8 @@ export default { loadApplications(["DATATYPE", "REFERENCETYPE", "CONFIGURATION", "ADDITIONALFILE"]); }); - function sortedApplicationsListForDate(localApplications) { - let apps = applications.value || applications; - localApplications = apps.sort((a, b) => { + function sortedApplicationsListForDate(localApplications, event) { + localApplications = applications.value.sort((a, b) => { const localA = new Date( a.updateDate[0], a.updateDate[1] - 1, @@ -213,15 +210,23 @@ export default { b.updateDate[5], b.updateDate[6] / 1000000 ); - return checkboxDate.value + return event === "0_9" ? localB.getTime() - localA.getTime() : localA.getTime() - localB.getTime(); }); - console.log( - "applicationsListOrderOrFilter in computed", - checkboxDate.value, - localApplications - ); + return localApplications; + } + + function sortedApplicationsListForName(localApplications, event) { + if (event === "Az") { + localApplications = localApplications.sort((a, b) => + a.localName.localeCompare(b.localName) + ); + } else if (event === "Za") { + localApplications = localApplications + .sort((a, b) => a.localName.localeCompare(b.localName)) + .reverse(); + } return localApplications; } @@ -264,9 +269,11 @@ export default { loading, selectedName, checkboxDate, - alphabeticalSort, + alphabeticalOrDateSort, isCardModalActive, canCreateApplication, + sortedApplicationsListForDate, + sortedApplicationsListForName }; }, }; -- GitLab From 7b851f5e6000e5c9f644f9ae00824715ef0e1c7b Mon Sep 17 00:00:00 2001 From: lucile varloteaux <lucile.varloteaux@inrae.fr> Date: Thu, 28 Nov 2024 14:09:06 +0100 Subject: [PATCH 3/4] suppression de variable non utile dans applicationCreationView.vue --- src/views/application/ApplicationCreationView.vue | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/src/views/application/ApplicationCreationView.vue b/src/views/application/ApplicationCreationView.vue index a873691c2..b93c1499d 100644 --- a/src/views/application/ApplicationCreationView.vue +++ b/src/views/application/ApplicationCreationView.vue @@ -207,7 +207,6 @@ export default { let disabled = useBoolean().refBoolean; let counter = useNumber(1).refNumber; let isLoading = computed(() => counter.value === 0); - let regExp = /^[a-zA-Z]+$/; async function saveApplication(status) { counter.value = 0; @@ -258,10 +257,6 @@ export default { await saveApplication("validate"); } - function validNameApplication(name) { - return regExp.test(name); - } - function showHelp() { let routeData = app.$router.resolve("/help"); window.open(routeData.href, "_blank"); @@ -279,12 +274,6 @@ export default { function parseResultChunck(chunk, caller) { const response = chunk.result; if ("validate" === caller && response.name) { - console.log( - testStringWithRegexArray( - response.configuration.applicationDescription.name.toLowerCase(), - currentUser.authorizations - ) - ); if ( response.configuration.applicationDescription.name.length < 44 && (currentUser.authorizations.includes( @@ -402,7 +391,6 @@ export default { return { createApplication, - validNameApplication, changeConfiguration, showHelp, testApplication, -- GitLab From 7a5434626b4777663912a2d8f23a09cf34291998 Mon Sep 17 00:00:00 2001 From: lucile varloteaux <lucile.varloteaux@inrae.fr> Date: Thu, 28 Nov 2024 16:48:38 +0100 Subject: [PATCH 4/4] =?UTF-8?q?r=C3=A9paration=20des=20display=20pour=20ma?= =?UTF-8?q?ny=20et=20dataLink?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/datas/DatasLink.vue | 2 +- src/components/datas/DatasManyLink.vue | 43 ++++++++++++++++---------- src/composable/data/dataLoader.js | 26 +++------------- src/model/application/Component.js | 10 ------ src/views/data/DataTableView.vue | 3 +- 5 files changed, 34 insertions(+), 50 deletions(-) diff --git a/src/components/datas/DatasLink.vue b/src/components/datas/DatasLink.vue index 924168666..7381d00ce 100644 --- a/src/components/datas/DatasLink.vue +++ b/src/components/datas/DatasLink.vue @@ -24,7 +24,7 @@ reference ? reference.localName !== value ? getValueDisplay(reference.rows[0], application) - : reference.localName + : displayValue : value }} </p> diff --git a/src/components/datas/DatasManyLink.vue b/src/components/datas/DatasManyLink.vue index 9c052dcc4..d46d4873f 100644 --- a/src/components/datas/DatasManyLink.vue +++ b/src/components/datas/DatasManyLink.vue @@ -8,8 +8,8 @@ :application="application" :column-id="val.columnName" :display-value=" - displaysForRow?.[referenceType]?.[val] && typeof val !== 'number' - ? displaysForRow?.[referenceType]?.[val] + displayValuesByReferenceAndValue[referenceType + '_' + val] && typeof val !== 'number' + ? displayValuesByReferenceAndValue[referenceType + '_' + val] : val.toString() " :loaded-references-by-key="{}" @@ -62,8 +62,8 @@ import services from "@/composable/services"; import DatasLink from "@/components/datas/DatasLink.vue"; import DatasDynamicLink from "@/components/datas/DatasDynamicLink.vue"; -import { datePatternLang } from "../../composable/application/DatePattern"; -import { computed } from "vue"; +import { datePatternLang } from "@/composable/application/DatePattern"; +import { computed, inject, onMounted, ref } from "vue"; export default { name: "DatasManyLink", @@ -99,7 +99,28 @@ export default { let refValues = { active: false }; let isCardModalActive = false; let modalArrayObj = {}; + const displayValuesByReferenceAndValue = ref({}); const dataService = services.dataService; + const { getValueDisplay, getOrLoadDataByNaturalKey } = inject("reference:dataLoader"); + + onMounted(async () => { + const newValues = {}; + for (let value of props.infoValues) { + if ( + !Object.keys(displayValuesByReferenceAndValue).includes(props.referenceType + "_" + value) + ) { + let ref = await getOrLoadDataByNaturalKey(props.application, props.referenceType, value); + newValues[props.referenceType + "_" + value] = getValueDisplay( + ref.values, + props.application + ); + } + } + displayValuesByReferenceAndValue.value = { + ...displayValuesByReferenceAndValue.value, + ...newValues, + }; + }); const applicationName = computed(() => { return props.application.name; @@ -180,17 +201,6 @@ export default { return localRefValues; } - function showBtnTablDynamicColumn(tablDynamicColumn) { - let showModal = Object.entries(tablDynamicColumn) - .filter((a) => a[1]) - .map(function (a) { - let obj = {}; - obj[a[0]] = a[1]; - return obj; - }); - return showModal.length !== 0; - } - function showModal() { isCardModalActive = true; modalArrayObj = Object.entries(this.infoValues) @@ -217,7 +227,7 @@ export default { datePatternLang, dynamicColumnReferences, openReferenceDetail, - showBtnTablDynamicColumn, + displayValuesByReferenceAndValue, showModal, refValues, dataService, @@ -225,6 +235,7 @@ export default { modalArrayObj, applicationName, columnTitle, + getValueDisplay, }; }, }; diff --git a/src/composable/data/dataLoader.js b/src/composable/data/dataLoader.js index 46cf14601..1ab096794 100644 --- a/src/composable/data/dataLoader.js +++ b/src/composable/data/dataLoader.js @@ -8,9 +8,10 @@ export function dataLoader(services) { if (reference) { return reference; } - if (typeof key === "string") - reference = await dataService.getDataByNaturalKey(applicationName, referenceName, key); - if (!reference) { + try { + if (typeof key === "string") + reference = await dataService.getDataByNaturalKey(applicationName, referenceName, key); + } catch (e) { return null; } reference = { @@ -48,25 +49,6 @@ export function dataLoader(services) { if (referenceLocal.values["display_" + services.internationalisationService.getLocale()]) { return referenceLocal.values["display_" + services.internationalisationService.getLocale()]; } - if ( - referenceLocal.values[ - "display_" + services.internationalisationService.getLocale() - ] - ) { - return referenceLocal.values[ - "display_" + services.internationalisationService.getLocale() - ]; - } - if ( - application && - referenceLocal.values[ - "display_" + application.configuration.applicationDescription.defaultLanguage - ] - ) { - return referenceLocal.values[ - "display_" + application.configuration.applicationDescription.defaultLanguage - ]; - } if ( application && referenceLocal.values[ diff --git a/src/model/application/Component.js b/src/model/application/Component.js index 22838f577..9843901ba 100644 --- a/src/model/application/Component.js +++ b/src/model/application/Component.js @@ -54,16 +54,6 @@ export class Component { return row.values[this.id]; } - getDisplayValue = function (row) { - let columnValue = this.getColumnValue(row); - let displaysForRow = row.displaysForRow?.[this.refLinkedTo]?.[row.values[this.id]]; - if (displaysForRow && typeof columnValue !== "number") { - return displaysForRow; - } else { - return "" + columnValue; - } - }; - order() { let order = (this.tags || []).find( (tag) => tag.tagDefinition === "ORDER_TAG" || tag.type === "ORDER_TAG" diff --git a/src/views/data/DataTableView.vue b/src/views/data/DataTableView.vue index ded9b3355..8d71eba45 100644 --- a/src/views/data/DataTableView.vue +++ b/src/views/data/DataTableView.vue @@ -135,7 +135,7 @@ :column-id="getRefColumnId(props.row, column)" :column-title="getColumnNameView(column.id, application, dataId, column)" :component="props.row" - :display-value="'' + column.getDisplayValue(props.row, column)" + :display-value="'' + loader.getValueDisplay(props.row, application)" :loaded-references-by-key="{}" :pattern-checker-date="patternCheckerDateRef(application, column.title, dataId)" :reference-type="column.refLinkedTo" @@ -634,6 +634,7 @@ export default { patternCheckerDateRef, totalRows, tableHeight, + loader, }; }, }; -- GitLab