|
2 | 2 | <!-- Project name --> |
3 | 3 | <article class="mb-5"> |
4 | 4 | <lf-field label-text="Project name" :required="true"> |
| 5 | + <template #label> |
| 6 | + <label class="c-field__label leading-5"> |
| 7 | + Project name <span class="c-field__required">*</span> |
| 8 | + </label> |
| 9 | + <div |
| 10 | + v-if="newForm && oldForm?.name !== newForm.name" |
| 11 | + class="flex items-center p-1 rounded-md bg-gray-100 gap-2 cursor-pointer text-gray-500 text-tiny font-semibold" |
| 12 | + > |
| 13 | + <span |
| 14 | + class="hover:bg-gray-200 px-1.5 py-0.5 rounded-xmd" |
| 15 | + :class="switcher.name ? 'bg-white text-gray-900' : ''" |
| 16 | + @click="!switcher.name ? useOldData(['name']) : null" |
| 17 | + >Old data</span> |
| 18 | + <span |
| 19 | + class="hover:bg-gray-200 px-1.5 py-0.5 rounded-xmd" |
| 20 | + :class="switcher.name ? '' : 'bg-white text-gray-900'" |
| 21 | + @click="switcher.name ? useNewData(['name']) : null" |
| 22 | + >updated data</span> |
| 23 | + </div> |
| 24 | + </template> |
5 | 25 | <lf-input |
6 | 26 | v-model="cForm.name" |
7 | 27 | class="h-10" |
|
19 | 39 | <!-- Description --> |
20 | 40 | <article class="mb-5"> |
21 | 41 | <lf-field label-text="Description" :required="true"> |
| 42 | + <template #label> |
| 43 | + <label class="c-field__label leading-5"> |
| 44 | + Description <span class="c-field__required">*</span> |
| 45 | + </label> |
| 46 | + <div |
| 47 | + v-if="newForm && oldForm?.description !== newForm.description" |
| 48 | + class="flex items-center p-1 rounded-md bg-gray-100 gap-2 cursor-pointer text-gray-500 text-tiny font-semibold" |
| 49 | + > |
| 50 | + <span |
| 51 | + class="hover:bg-gray-200 px-1.5 py-0.5 rounded-xmd" |
| 52 | + :class="switcher.description ? 'bg-white text-gray-900' : ''" |
| 53 | + @click="!switcher.description ? useOldData(['description']) : null" |
| 54 | + >Old data</span> |
| 55 | + <span |
| 56 | + class="hover:bg-gray-200 px-1.5 py-0.5 rounded-xmd" |
| 57 | + :class="switcher.description ? '' : 'bg-white text-gray-900'" |
| 58 | + @click="switcher.description ? useNewData(['description']) : null" |
| 59 | + >updated data</span> |
| 60 | + </div> |
| 61 | + </template> |
22 | 62 | <lf-textarea |
23 | 63 | v-model="cForm.description" |
24 | 64 | :invalid="$v.description.$invalid && $v.description.$dirty" |
|
35 | 75 | <!-- Logo --> |
36 | 76 | <article class="mb-5"> |
37 | 77 | <lf-field label-text="Logo URL" :required="true"> |
| 78 | + <template #label> |
| 79 | + <label class="c-field__label leading-5"> |
| 80 | + Logo URL <span class="c-field__required">*</span> |
| 81 | + </label> |
| 82 | + <div |
| 83 | + v-if="newForm && oldForm?.logoUrl !== newForm.logoUrl" |
| 84 | + class="flex items-center p-1 rounded-md bg-gray-100 gap-2 cursor-pointer text-gray-500 text-tiny font-semibold" |
| 85 | + > |
| 86 | + <span |
| 87 | + class="hover:bg-gray-200 px-1.5 py-0.5 rounded-xmd" |
| 88 | + :class="switcher.logoUrl ? 'bg-white text-gray-900' : ''" |
| 89 | + @click="!switcher.logoUrl ? useOldData(['logoUrl']) : null" |
| 90 | + >Old data</span> |
| 91 | + <span |
| 92 | + class="hover:bg-gray-200 px-1.5 py-0.5 rounded-xmd" |
| 93 | + :class="switcher.logoUrl ? '' : 'bg-white text-gray-900'" |
| 94 | + @click="switcher.logoUrl ? useNewData(['logoUrl']) : null" |
| 95 | + >updated data</span> |
| 96 | + </div> |
| 97 | + </template> |
38 | 98 | <lf-input |
39 | 99 | v-model="cForm.logoUrl" |
40 | 100 | class="h-10" |
|
52 | 112 | <!-- topics --> |
53 | 113 | <article class="mb-5"> |
54 | 114 | <lf-field label-text="Topics"> |
| 115 | + <template #label> |
| 116 | + <label class="c-field__label leading-5"> Topics </label> |
| 117 | + <div |
| 118 | + v-if="newForm" |
| 119 | + class="flex items-center p-1 rounded-md bg-gray-100 gap-2 cursor-pointer text-gray-500 text-tiny font-semibold" |
| 120 | + > |
| 121 | + <span |
| 122 | + class="hover:bg-gray-200 px-1.5 py-0.5 rounded-xmd" |
| 123 | + :class="switcher.keywords ? 'bg-white text-gray-900' : ''" |
| 124 | + @click="!switcher.keywords ? useOldData(['keywords']) : null" |
| 125 | + >Old data</span> |
| 126 | + <span |
| 127 | + class="hover:bg-gray-200 px-1.5 py-0.5 rounded-xmd" |
| 128 | + :class="switcher.keywords ? '' : 'bg-white text-gray-900'" |
| 129 | + @click="switcher.keywords ? useNewData(['keywords']) : null" |
| 130 | + >updated data</span> |
| 131 | + </div> |
| 132 | + </template> |
55 | 133 | <app-keywords-input |
56 | 134 | v-model="cForm.keywords" |
57 | 135 | :show-hint="true" |
|
102 | 180 |
|
103 | 181 | <hr class="my-5" /> |
104 | 182 |
|
105 | | - <h6 class="font-semibold mb-6"> |
106 | | - Website & Social accounts |
107 | | - </h6> |
| 183 | + <div class="flex items-center justify-between mb-6"> |
| 184 | + <h6 class="font-semibold"> |
| 185 | + Website & Social accounts |
| 186 | + </h6> |
| 187 | + <div |
| 188 | + v-if="newForm" |
| 189 | + class="flex items-center p-1 rounded-md bg-gray-100 gap-2 cursor-pointer text-gray-500 text-tiny font-semibold" |
| 190 | + > |
| 191 | + <span |
| 192 | + class="hover:bg-gray-200 px-1.5 py-0.5 rounded-xmd" |
| 193 | + :class="switcher.website ? 'bg-white text-gray-900' : ''" |
| 194 | + @click=" |
| 195 | + !switcher.website |
| 196 | + ? useOldData(['website', 'github', 'twitter']) |
| 197 | + : null |
| 198 | + " |
| 199 | + >Old data</span> |
| 200 | + <span |
| 201 | + class="hover:bg-gray-200 px-1.5 py-0.5 rounded-xmd" |
| 202 | + :class="switcher.website ? '' : 'bg-white text-gray-900'" |
| 203 | + @click=" |
| 204 | + switcher.website ? useNewData(['website', 'github', 'twitter']) : null |
| 205 | + " |
| 206 | + >updated data</span> |
| 207 | + </div> |
| 208 | + </div> |
108 | 209 |
|
109 | 210 | <!-- Website --> |
110 | 211 | <article class="mb-5"> |
@@ -158,18 +259,51 @@ import LfTextarea from '@/ui-kit/textarea/Textarea.vue'; |
158 | 259 | import LfFieldMessages from '@/ui-kit/field-messages/FieldMessages.vue'; |
159 | 260 | import LfIcon from '@/ui-kit/icon/Icon.vue'; |
160 | 261 | import useVuelidate from '@vuelidate/core'; |
161 | | -import { reactive } from 'vue'; |
| 262 | +import { reactive, ref } from 'vue'; |
162 | 263 | import AppKeywordsInput from '@/shared/form/keywords-input.vue'; |
163 | 264 | import { InsightsProjectAddFormModel } from '../models/insights-project-add-form.model'; |
164 | 265 | import LfInsightsProjectsAddCollectionDropdown from './add-details-tab/lf-insights-projects-add-collection-dropdown.vue'; |
165 | 266 | import LfInsightsProjectsAddOrganizationsDropdown from './add-details-tab/lf-insights-projects-add-organizations-dropdown.vue'; |
166 | 267 |
|
167 | 268 | const props = defineProps<{ |
168 | 269 | form: InsightsProjectAddFormModel; |
| 270 | + oldForm?: InsightsProjectAddFormModel; |
| 271 | + newForm?: InsightsProjectAddFormModel; |
169 | 272 | rules: any; |
170 | 273 | }>(); |
171 | 274 | const cForm = reactive(props.form); |
172 | 275 | const $v = useVuelidate(props.rules, cForm); |
| 276 | +const switcher = ref<Record<string, boolean>>({ |
| 277 | + name: true, |
| 278 | + description: true, |
| 279 | + logoUrl: true, |
| 280 | + keywords: true, |
| 281 | + github: true, |
| 282 | + twitter: true, |
| 283 | + website: true, |
| 284 | +}); |
| 285 | +
|
| 286 | +const useNewData = (fields: string[]) => { |
| 287 | + fields.forEach((field) => { |
| 288 | + switcher.value[field] = false; |
| 289 | + if (props.newForm) { |
| 290 | + cForm[field as keyof InsightsProjectAddFormModel] = props.newForm[ |
| 291 | + field as keyof InsightsProjectAddFormModel |
| 292 | + ] as any; |
| 293 | + } |
| 294 | + }); |
| 295 | +}; |
| 296 | +
|
| 297 | +const useOldData = (fields: string[]) => { |
| 298 | + fields.forEach((field) => { |
| 299 | + switcher.value[field] = true; |
| 300 | + if (props.oldForm) { |
| 301 | + cForm[field as keyof InsightsProjectAddFormModel] = props.oldForm[ |
| 302 | + field as keyof InsightsProjectAddFormModel |
| 303 | + ] as any; |
| 304 | + } |
| 305 | + }); |
| 306 | +}; |
173 | 307 | </script> |
174 | 308 |
|
175 | 309 | <script lang="ts"> |
|
0 commit comments