|
2 | 2 | <app-dialog v-if="computedVisible" v-model="computedVisible" title="Edit attributes">
|
3 | 3 | <template #content>
|
4 | 4 | <div class="px-6 pb-6">
|
5 |
| - <el-form ref="form" :model="formInline" class="attributes-form"> |
| 5 | + <el-form :model="form" class="attributes-form"> |
6 | 6 | <div class="rounded-md bg-yellow-50 border border-yellow-100 flex items-center gap-2 py-3 px-4 mt-2">
|
7 | 7 | <i class="ri-alert-fill text-yellow-500 text-base " />
|
8 | 8 | <span class="text-xs leading-5 text-gray-900">Some changes may overwrite current attributes from the
|
9 | 9 | selected members.</span>
|
10 | 10 | </div>
|
11 | 11 | <!-- <h2 class="text-lg font-semibold mb-4">Attributes</h2> -->
|
12 | 12 |
|
13 |
| - <div class="mt-6 mb-8 flex flex-col gap-4"> |
| 13 | + <!-- <div class="mt-6 mb-8 flex flex-col gap-4"> |
14 | 14 | <h6 class="text-xs text-gray-400">
|
15 | 15 | DEFAULT ATTRIBUTES
|
16 | 16 | </h6>
|
|
35 | 35 | <el-input v-model="computedVisible" type="text" class="flex-grow ml-4" />
|
36 | 36 | </div>
|
37 | 37 |
|
38 |
| - </div> |
39 |
| - <div class="mt-4 flex flex-col gap-8"> |
| 38 | + </div> --> |
| 39 | + <div class="mt-6 mb-10 flex flex-col gap-8"> |
40 | 40 | <h6 class="text-xs text-gray-400">
|
41 | 41 | CUSTOM ATTRIBUTES
|
42 | 42 | </h6>
|
43 | 43 |
|
44 |
| - <div class="flex"> |
45 |
| - <div class="flex flex-col flex-shrink-0 w-1/3"> |
46 |
| - <span class="text-xs font-medium text-black">Organizations</span> |
47 |
| - <p class="text-2xs"> |
48 |
| - {attribute type} |
49 |
| - </p> |
50 |
| - </div> |
51 |
| - <el-input v-model="computedVisible" type="text" class="flex-grow ml-4" /> |
52 |
| - </div> |
53 |
| - |
54 |
| - <div class="flex"> |
55 |
| - <div class="flex flex-col flex-shrink-0 w-1/3"> |
56 |
| - <span class="text-xs font-medium text-black">Website</span> |
57 |
| - <p class="text-2xs"> |
58 |
| - URL |
59 |
| - </p> |
60 |
| - </div> |
61 |
| - <el-input v-model="computedVisible" type="text" class="flex-grow ml-4" /> |
62 |
| - </div> |
63 |
| - |
64 |
| - <div class="flex"> |
| 44 | + <div v-for="(attribute, index) in customAttributes" :key="index" class="flex"> |
65 | 45 | <div class="flex flex-col flex-shrink-0 w-1/3">
|
66 |
| - <span class="text-xs font-medium text-black">is Hireable</span> |
67 |
| - <p class="text-2xs"> |
68 |
| - Boolean |
69 |
| - </p> |
70 |
| - </div> |
71 |
| - <el-input v-model="computedVisible" type="text" class="flex-grow ml-4" /> |
72 |
| - </div> |
73 |
| - |
74 |
| - <div class="flex"> |
75 |
| - <div class="flex flex-col flex-shrink-0 w-1/3"> |
76 |
| - <span class="text-xs font-medium text-black">{attribute}</span> |
77 |
| - <p class="text-2xs"> |
78 |
| - {attribute type} |
| 46 | + <span class="text-xs font-medium text-gray-900">{{ attribute.label }}</span> |
| 47 | + <p class="text-2xs text-gray-500"> |
| 48 | + {{ attributesTypes[attribute.type] }} |
79 | 49 | </p>
|
80 | 50 | </div>
|
81 |
| - <el-input v-model="computedVisible" type="text" class="flex-grow ml-4" /> |
82 |
| - </div> |
83 | 51 |
|
84 |
| - <div class="flex"> |
85 |
| - <div class="flex flex-col flex-shrink-0 w-1/3"> |
86 |
| - <span class="text-xs font-medium text-black">{attribute}</span> |
87 |
| - <p class="text-2xs"> |
88 |
| - {attribute type} |
89 |
| - </p> |
90 |
| - </div> |
91 |
| - <el-input v-model="computedVisible" type="text" class="flex-grow ml-4" /> |
| 52 | + <el-date-picker |
| 53 | + v-if="attribute.type === 'date'" |
| 54 | + v-model="model[attribute.name]" |
| 55 | + :prefix-icon="CalendarIcon" |
| 56 | + :clearable="false" |
| 57 | + class="custom-date-picker" |
| 58 | + popper-class="date-picker-popper" |
| 59 | + type="date" |
| 60 | + value-format="YYYY-MM-DD" |
| 61 | + format="YYYY-MM-DD" |
| 62 | + placeholder="YYYY-MM-DD" |
| 63 | + /> |
| 64 | + <!-- <app-autocomplete-many-input |
| 65 | + v-else-if="attribute.type === 'multiSelect'" |
| 66 | + v-model="model[attribute.name]" |
| 67 | + :fetch-fn=" |
| 68 | + () => fetchCustomAttribute(attribute.id) |
| 69 | + " |
| 70 | + :create-fn=" |
| 71 | + (value) => |
| 72 | + updateCustomAttribute(attribute, value) |
| 73 | + " |
| 74 | + placeholder="Select an option or create one" |
| 75 | + input-class="w-full multi-select-field" |
| 76 | + :create-if-not-found="true" |
| 77 | + :collapse-tags="true" |
| 78 | + :parse-model="true" |
| 79 | + :are-options-in-memory="true" |
| 80 | + /> --> |
| 81 | + <el-select |
| 82 | + v-else-if="attribute.type === 'boolean'" |
| 83 | + v-model="model[attribute.name]" |
| 84 | + class="w-full" |
| 85 | + clearable |
| 86 | + placeholder="Select option" |
| 87 | + > |
| 88 | + <el-option |
| 89 | + key="true" |
| 90 | + label="True" |
| 91 | + :value="true" |
| 92 | + @mouseleave="onSelectMouseLeave" |
| 93 | + /> |
| 94 | + <el-option |
| 95 | + key="false" |
| 96 | + label="False" |
| 97 | + :value="false" |
| 98 | + @mouseleave="onSelectMouseLeave" |
| 99 | + /> |
| 100 | + </el-select> |
| 101 | + |
| 102 | + <el-input |
| 103 | + v-else |
| 104 | + v-model="model[attribute.name]" |
| 105 | + :type="attribute.type" |
| 106 | + clearable |
| 107 | + /> |
92 | 108 | </div>
|
93 | 109 | </div>
|
94 | 110 | </el-form>
|
|
106 | 122 | </app-dialog>
|
107 | 123 | </template>
|
108 | 124 |
|
109 |
| -<script> |
| 125 | +<script setup> |
110 | 126 | import { mapActions } from 'vuex';
|
111 | 127 | import { storeToRefs } from 'pinia';
|
112 |
| -import { reactive } from 'vue'; |
| 128 | +import { |
| 129 | + reactive, ref, computed, h, |
| 130 | +} from 'vue'; |
113 | 131 | import { MemberModel } from '@/modules/member/member-model';
|
114 | 132 | import AppDialog from '@/shared/dialog/dialog.vue';
|
115 |
| -import AppTagAutocompleteInput from '@/modules/tag/components/tag-autocomplete-input.vue'; |
116 | 133 | import { FormSchema } from '@/shared/form/form-schema';
|
117 | 134 | import { useMemberStore } from '@/modules/member/store/pinia';
|
118 |
| -import AppFormItem from '@/shared/form/form-item.vue'; |
| 135 | +
|
| 136 | +const CalendarIcon = h( |
| 137 | + 'i', // type |
| 138 | + { |
| 139 | + class: |
| 140 | + 'ri-calendar-line text-base leading-none text-gray-400', |
| 141 | + }, // props |
| 142 | + [], |
| 143 | +); |
119 | 144 |
|
120 | 145 | const memberStore = useMemberStore();
|
121 | 146 | const { selectedMembers } = storeToRefs(memberStore);
|
122 | 147 |
|
123 | 148 | const { fields } = MemberModel;
|
| 149 | +const formSchema = new FormSchema([fields.attributes]); |
124 | 150 |
|
125 |
| -const formInline = reactive({ |
126 |
| - user: '', |
127 |
| - region: '', |
128 |
| - date: '', |
| 151 | +const props = defineProps({ |
| 152 | + modelValue: { |
| 153 | + type: Boolean, |
| 154 | + default: false, |
| 155 | + }, |
129 | 156 | });
|
130 | 157 |
|
131 |
| -export default { |
132 |
| - name: 'AppEditAttributesPopover', |
133 |
| - components: { AppDialog, AppFormItem }, |
| 158 | +const emits = defineEmits(['reload', 'update:modelValue']); |
134 | 159 |
|
135 |
| - props: { |
136 |
| - modelValue: { |
137 |
| - type: Boolean, |
138 |
| - default: () => false, |
139 |
| - }, |
140 |
| - }, |
141 |
| - emits: ['reload', 'update:modelValue'], |
| 160 | +const attributesTypes = { |
| 161 | + string: 'Text', |
| 162 | + number: 'Number', |
| 163 | + email: 'E-mail', |
| 164 | + url: 'URL', |
| 165 | + date: 'Date', |
| 166 | + boolean: 'Boolean', |
| 167 | + multiSelect: 'Multi-select', |
| 168 | +}; |
142 | 169 |
|
143 |
| - data() { |
144 |
| - return { |
145 |
| - loading: false, |
146 |
| - }; |
147 |
| - }, |
| 170 | +const loading = ref(false); |
148 | 171 |
|
149 |
| - computed: { |
150 |
| - fields() { |
151 |
| - return fields; |
152 |
| - }, |
153 |
| - computedVisible: { |
154 |
| - get() { |
155 |
| - return this.modelValue; |
156 |
| - }, |
157 |
| - set() { |
158 |
| - this.$emit('update:modelValue', false); |
159 |
| - }, |
160 |
| - }, |
161 |
| - }, |
| 172 | +const model = ref({ |
| 173 | + yearsOfExperience: '', |
| 174 | + country: '', |
| 175 | + isHireable: '', |
| 176 | + expertise: '', |
| 177 | + seniorityLevel: '', |
| 178 | +}) |
162 | 179 |
|
163 |
| - methods: { |
164 |
| - async handleSubmit() { |
165 |
| - this.loading = true; |
166 |
| - // do something |
167 |
| - }, |
168 |
| -
|
169 |
| - handleCancel() { |
170 |
| - this.editTagsModel = []; |
171 |
| - this.editTagsInCommon = []; |
172 |
| - this.computedVisible = false; |
173 |
| - }, |
| 180 | +const customAttributes = [ |
| 181 | + { |
| 182 | + label: 'Years of Experience', name: 'yearsOfExperience', type: 'number', |
| 183 | + }, |
| 184 | + { |
| 185 | + label: 'Country', name: 'country', type: 'string', |
| 186 | + }, |
| 187 | + { |
| 188 | + label: 'is Hireable', name: 'isHireable', type: 'boolean', |
| 189 | + }, |
| 190 | + { |
| 191 | + label: 'Expertise', name: 'expertise', type: 'multiSelect', |
174 | 192 | },
|
| 193 | + { |
| 194 | + label: 'Skills', name: 'skills', type: 'multiSelect', |
| 195 | + }, |
| 196 | + { |
| 197 | + label: 'Seniority Level', name: 'seniorityLevel', type: 'string', |
| 198 | + }, |
| 199 | +]; |
| 200 | +
|
| 201 | +const handleSubmit = async () => { |
| 202 | + this.loading = true; |
| 203 | + // do something |
| 204 | + console.log("helo", this.model); |
175 | 205 | };
|
176 |
| -</script> |
177 | 206 |
|
178 |
| -<style scoped></style> |
| 207 | +const handleCancel = () => { |
| 208 | + computeVisible.value = false; |
| 209 | +}; |
| 210 | +
|
| 211 | +const computedVisible = computed({ |
| 212 | + get() { |
| 213 | + return props.modelValue; |
| 214 | + }, |
| 215 | + set() { |
| 216 | + emits['update:modelValue'](false); |
| 217 | + }, |
| 218 | +}); |
| 219 | +
|
| 220 | +</script> |
0 commit comments