3939 "
4040 ok-only
4141 :ok-disabled ="
42- !contributors.photographe.size || !contributors.createur.size
42+ !contributorsByContributionType.photographe.size ||
43+ !contributorsByContributionType.createur.size
4344 "
4445 :ok-title =" $t(action === 'export' ? 'Export' : 'Submit')"
4546 @ok =" onOK"
5960 >
6061 <h2 >{{ $t(ucFirst(userContributionEnL10n[contributionType])) }}</h2 >
6162 <b-alert
62- :model-value =" !contributors[contributionType].size"
63+ :model-value ="
64+ !contributorsByContributionType[contributionType].size
65+ "
6366 variant =" warning"
6467 >
6568 {{ $t("You should select at least one user") }} </b-alert
7073 :min-input-length =" 0"
7174 @select-item ="
7275 (user: SimpleUser) => {
73- contributors [contributionType as contribution].add(user);
76+ contributorsByContributionType [contributionType as contribution].add(user);
7477 }
7578 "
7679 />
7780 <ul >
7881 <li
79- v-for =" contributor in contributors [contributionType]"
82+ v-for =" contributor in contributorsByContributionType [contributionType as contribution ]"
8083 :key =" contributor.username"
8184 >
8285 {{ contributor.username }}
8386 <i-bi-x-square-fill
8487 class =" clickable"
8588 @click ="
86- contributors [contributionType as contribution].delete(
89+ contributorsByContributionType [contributionType as contribution].delete(
8790 contributor,
8891 );
8992 "
@@ -107,16 +110,17 @@ import type { contribution } from "~prisma-schemas/schemas/edgecreator";
107110import type { SimpleUser } from " ~types/SimpleUser" ;
108111import { stores as webStores } from " ~web" ;
109112
110- const userContributionEnL10n: Record < contribution , string > = {
113+ const userContributionEnL10n = {
111114 photographe: " photographers" ,
112115 createur: " designers" ,
113- };
116+ } as const ;
114117
115118const { saveEdgeSvg } = saveEdge ();
116119
117120const { t : $t } = useI18n ();
118121const userStore = webStores .users ();
119122const mainStore = main ();
123+ const { issuecodes, contributors } = storeToRefs (mainStore );
120124
121125const { action } = defineProps <{
122126 action: " save" | " submit" | " export" ;
@@ -127,10 +131,10 @@ const progress = ref(0);
127131const issueIndexToSave = ref <number >();
128132const result = ref <string >();
129133
130- const contributors = ref < Record < contribution , Set < SimpleUser >>> ({
131- photographe: new Set (),
132- createur: new Set (),
133- });
134+ const contributorsByContributionType = ref ({
135+ photographe: new Set < SimpleUser > (),
136+ createur: new Set < SimpleUser > (),
137+ } as const );
134138
135139const label = computed (() => $t (ucFirst (action )));
136140
@@ -150,8 +154,7 @@ watch(progress, (newValue) => {
150154 }
151155});
152156watch (issueIndexToSave , (newValue ) => {
153- console .log (" issueIndexToSave" , newValue );
154- const currentIssuecode = mainStore .issuecodes [newValue ! ];
157+ const currentIssuecode = issuecodes .value [newValue ! ];
155158
156159 if (currentIssuecode === undefined ) {
157160 return ;
@@ -161,15 +164,15 @@ watch(issueIndexToSave, (newValue) => {
161164 nextTick (() => {
162165 saveEdgeSvg (
163166 currentIssuecode ,
164- Array .from (mainStore . contributors ).filter (
167+ Array .from (contributors . value ).filter (
165168 ({ issuecode }) => issuecode === currentIssuecode ,
166169 ),
167170 action === " export" ,
168171 action === " submit" ,
169172 ).then ((response ) => {
170173 const isSuccess = response ! .paths .svgPath ;
171174 if (isSuccess ) {
172- progress .value += 100 / mainStore . issuecodes .length ;
175+ progress .value += 100 / issuecodes . value .length ;
173176 issueIndexToSave .value ! ++ ;
174177 } else {
175178 progress .value = 0 ;
@@ -185,8 +188,10 @@ const onOK = () => {
185188 for (const contributionType of Object .keys (
186189 contributors .value ,
187190 ) as contribution []) {
188- for (const contributor of contributors .value [contributionType ]) {
189- for (const issuecode of mainStore .issuecodes ) {
191+ for (const contributor of contributorsByContributionType .value [
192+ contributionType
193+ ]) {
194+ for (const issuecode of issuecodes .value ) {
190195 mainStore .addContributor ({
191196 issuecode ,
192197 contributionType ,
@@ -204,7 +209,8 @@ const ucFirst = (text: string) =>
204209
205210const getUsersWithoutContributors = (contributionType : contribution ) =>
206211 userStore .allUsers ! .filter (
207- (contributor ) => ! contributors .value [contributionType ].has (contributor ),
212+ (contributor ) =>
213+ ! contributorsByContributionType .value [contributionType ].has (contributor ),
208214 );
209215
210216const onClick = () => {
@@ -214,6 +220,21 @@ const onClick = () => {
214220 issueIndexToSave .value = 0 ;
215221 }
216222};
223+
224+ onMounted (() => {
225+ contributorsByContributionType .value = {
226+ photographe: new Set (
227+ Array .from (contributors .value )
228+ .filter (({ contributionType }) => contributionType === " photographe" )
229+ .map (({ user }) => user ),
230+ ),
231+ createur: new Set (
232+ Array .from (contributors .value )
233+ .filter (({ contributionType }) => contributionType === " createur" )
234+ .map (({ user }) => user ),
235+ ),
236+ };
237+ });
217238 </script >
218239<style scoped lang="scss">
219240:deep(.btn ) {
0 commit comments