mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-03 22:47:45 +00:00
Restore features after merging
This commit is contained in:
parent
392fd01b56
commit
0204bdd38d
@ -1,7 +1,11 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="grey-card">
|
<div class="grey-card">
|
||||||
<ul :class="listClasses" v-if="picked.length && displayPicked">
|
<ul :class="listClasses" v-if="picked.length && displayPicked">
|
||||||
<li v-for="p in picked" @click="removeEntity(p)" :key="p.type + p.id">
|
<li
|
||||||
|
v-for="p in picked"
|
||||||
|
@click="removeEntity(p)"
|
||||||
|
:key="p === 'me' ? 'me' : p.type + p.id"
|
||||||
|
>
|
||||||
<span
|
<span
|
||||||
v-if="'me' === p"
|
v-if="'me' === p"
|
||||||
class="chill_denomination current-user updatedBy"
|
class="chill_denomination current-user updatedBy"
|
||||||
@ -21,10 +25,10 @@
|
|||||||
<li v-if="isCurrentUserPicker" class="btn btn-sm btn-misc">
|
<li v-if="isCurrentUserPicker" class="btn btn-sm btn-misc">
|
||||||
<label class="flex items-center gap-2">
|
<label class="flex items-center gap-2">
|
||||||
<input
|
<input
|
||||||
:checked="picked.indexOf('me') >= 0 ? true : null"
|
:checked="isMePicked"
|
||||||
ref="itsMeCheckbox"
|
ref="itsMeCheckbox"
|
||||||
:type="multiple ? 'checkbox' : 'radio'"
|
:type="multiple ? 'checkbox' : 'radio'"
|
||||||
@change="selectItsMe"
|
@change="selectItsMe($event as InputEvent)"
|
||||||
/>
|
/>
|
||||||
{{ trans(USER_CURRENT_USER) }}
|
{{ trans(USER_CURRENT_USER) }}
|
||||||
</label>
|
</label>
|
||||||
@ -42,7 +46,11 @@
|
|||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<ul class="badge-suggest add-items inline" style="float: right">
|
<ul class="badge-suggest add-items inline" style="float: right">
|
||||||
<li v-for="s in suggested" :key="s.id" @click="addNewSuggested(s)">
|
<li
|
||||||
|
v-for="s in suggested"
|
||||||
|
:key="s.type + s.id"
|
||||||
|
@click="addNewSuggested(s)"
|
||||||
|
>
|
||||||
<span :class="getBadgeClass(s)" :style="getBadgeStyle(s)">
|
<span :class="getBadgeClass(s)" :style="getBadgeStyle(s)">
|
||||||
{{ s.text }}
|
{{ s.text }}
|
||||||
</span>
|
</span>
|
||||||
@ -52,9 +60,21 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { ref, computed, defineProps, defineEmits, defineComponent } from "vue";
|
import {
|
||||||
|
ref,
|
||||||
|
computed,
|
||||||
|
defineProps,
|
||||||
|
defineEmits,
|
||||||
|
defineComponent,
|
||||||
|
withDefaults,
|
||||||
|
} from "vue";
|
||||||
import AddPersons from "ChillPersonAssets/vuejs/_components/AddPersons.vue";
|
import AddPersons from "ChillPersonAssets/vuejs/_components/AddPersons.vue";
|
||||||
import { Entities, EntityType, SearchOptions } from "ChillPersonAssets/types";
|
import {
|
||||||
|
Entities,
|
||||||
|
EntitiesOrMe,
|
||||||
|
EntityType,
|
||||||
|
SearchOptions,
|
||||||
|
} from "ChillPersonAssets/types";
|
||||||
import {
|
import {
|
||||||
PICK_ENTITY_MODAL_TITLE,
|
PICK_ENTITY_MODAL_TITLE,
|
||||||
PICK_ENTITY_USER,
|
PICK_ENTITY_USER,
|
||||||
@ -71,25 +91,28 @@ defineComponent({
|
|||||||
AddPersons,
|
AddPersons,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
const props = defineProps<{
|
const props = withDefaults(
|
||||||
|
defineProps<{
|
||||||
multiple: boolean;
|
multiple: boolean;
|
||||||
types: EntityType[];
|
types: EntityType[];
|
||||||
picked: Entities[];
|
picked: EntitiesOrMe[];
|
||||||
uniqid: string;
|
uniqid: string;
|
||||||
removableIfSet?: boolean;
|
removableIfSet?: boolean;
|
||||||
displayPicked?: boolean;
|
displayPicked?: boolean;
|
||||||
suggested?: Entities[];
|
suggested?: Entities[];
|
||||||
label?: string;
|
label?: string;
|
||||||
isCurrentUserPicker: boolean // must default to false
|
isCurrentUserPicker?: boolean;
|
||||||
}>();
|
}>(),
|
||||||
|
{ isCurrentUserPicker: false },
|
||||||
|
);
|
||||||
|
|
||||||
const emits = defineEmits<{
|
const emits = defineEmits<{
|
||||||
(e: "addNewEntity", payload: { entity: Entities }): void;
|
(e: "addNewEntity", payload: { entity: EntitiesOrMe }): void;
|
||||||
(e: "removeEntity", payload: { entity: Entities }): void;
|
(e: "removeEntity", payload: { entity: EntitiesOrMe }): void;
|
||||||
(e: "addNewEntityProcessEnded"): void;
|
(e: "addNewEntityProcessEnded"): void;
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
const itsMeCheckbox = ref(null);
|
const itsMeCheckbox = ref<null | HTMLInputElement>(null);
|
||||||
const addPersons = ref();
|
const addPersons = ref();
|
||||||
|
|
||||||
const addPersonsOptions = computed(
|
const addPersonsOptions = computed(
|
||||||
@ -105,6 +128,8 @@ const addPersonsOptions = computed(
|
|||||||
}) as SearchOptions,
|
}) as SearchOptions,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const isMePicked = computed<boolean>(() => props.picked.indexOf("me") >= 0);
|
||||||
|
|
||||||
const translatedListOfTypes = computed(() => {
|
const translatedListOfTypes = computed(() => {
|
||||||
if (props.label !== undefined && props.label !== "") {
|
if (props.label !== undefined && props.label !== "") {
|
||||||
return props.label;
|
return props.label;
|
||||||
@ -142,10 +167,12 @@ const listClasses = computed(() => ({
|
|||||||
inline: true,
|
inline: true,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
const selectItsMe = (event) =>
|
const selectItsMe = (event: InputEvent) => {
|
||||||
event.target.checked ? addNewSuggested("me") : removeEntity("me");
|
const target = event.target as HTMLInputElement;
|
||||||
|
target.checked ? addNewSuggested("me") : removeEntity("me");
|
||||||
|
};
|
||||||
|
|
||||||
function addNewSuggested(entity: Entities) {
|
function addNewSuggested(entity: EntitiesOrMe) {
|
||||||
emits("addNewEntity", { entity });
|
emits("addNewEntity", { entity });
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -158,8 +185,7 @@ function addNewEntity({ selected }: addNewEntities) {
|
|||||||
emits("addNewEntityProcessEnded");
|
emits("addNewEntityProcessEnded");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const removeEntity = (entity: EntitiesOrMe) => {
|
||||||
const removeEntity = (entity) => {
|
|
||||||
if (!props.removableIfSet) return;
|
if (!props.removableIfSet) return;
|
||||||
if (entity === "me" && itsMeCheckbox.value) {
|
if (entity === "me" && itsMeCheckbox.value) {
|
||||||
itsMeCheckbox.value.checked = false;
|
itsMeCheckbox.value.checked = false;
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
import { StoredObject } from "ChillDocStoreAssets/types";
|
|
||||||
import {
|
import {
|
||||||
Address,
|
Address,
|
||||||
Center,
|
Center,
|
||||||
@ -276,14 +275,16 @@ export type Entities = (UserGroup | User | Person | Thirdparty | Household) & {
|
|||||||
profession?: string;
|
profession?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type Result = Entities & {
|
export type EntitiesOrMe = "me" | Entities;
|
||||||
|
|
||||||
|
export type AddPersonResult = Entities & {
|
||||||
parent?: Entities | null;
|
parent?: Entities | null;
|
||||||
};
|
};
|
||||||
|
|
||||||
export interface Suggestion {
|
export interface Suggestion {
|
||||||
key: string;
|
key: string;
|
||||||
relevance: number;
|
relevance: number;
|
||||||
result: Result;
|
result: AddPersonResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface SearchPagination {
|
export interface SearchPagination {
|
||||||
|
@ -37,9 +37,7 @@
|
|||||||
id="search-persons"
|
id="search-persons"
|
||||||
name="query"
|
name="query"
|
||||||
v-model="query"
|
v-model="query"
|
||||||
:placeholder="
|
:placeholder="trans(ADD_PERSONS_SEARCH_SOME_PERSONS)"
|
||||||
trans(ADD_PERSONS_SEARCH_SOME_PERSONS)
|
|
||||||
"
|
|
||||||
ref="searchRef"
|
ref="searchRef"
|
||||||
/>
|
/>
|
||||||
<i class="fa fa-search fa-lg" />
|
<i class="fa fa-search fa-lg" />
|
||||||
@ -56,10 +54,7 @@
|
|||||||
<a v-if="suggestedCounter > 2" @click="selectAll">
|
<a v-if="suggestedCounter > 2" @click="selectAll">
|
||||||
{{ trans(ACTION_CHECK_ALL) }}
|
{{ trans(ACTION_CHECK_ALL) }}
|
||||||
</a>
|
</a>
|
||||||
<a
|
<a v-if="selectedCounter > 0" @click="resetSelection">
|
||||||
v-if="selectedCounter > 0"
|
|
||||||
@click="resetSelection"
|
|
||||||
>
|
|
||||||
<i v-if="suggestedCounter > 2"> • </i>
|
<i v-if="suggestedCounter > 2"> • </i>
|
||||||
{{ trans(ACTION_RESET) }}
|
{{ trans(ACTION_RESET) }}
|
||||||
</a>
|
</a>
|
||||||
@ -95,9 +90,7 @@
|
|||||||
(options.type.includes('person') ||
|
(options.type.includes('person') ||
|
||||||
options.type.includes('thirdparty'))
|
options.type.includes('thirdparty'))
|
||||||
"
|
"
|
||||||
:button-text="
|
:button-text="trans(ONTHEFLY_CREATE_BUTTON, { q: query })"
|
||||||
trans(ONTHEFLY_CREATE_BUTTON, { q: query })
|
|
||||||
"
|
|
||||||
:allowed-types="options.type"
|
:allowed-types="options.type"
|
||||||
:query="query"
|
:query="query"
|
||||||
action="create"
|
action="create"
|
||||||
@ -151,7 +144,7 @@ import {
|
|||||||
import {
|
import {
|
||||||
Suggestion,
|
Suggestion,
|
||||||
Search,
|
Search,
|
||||||
Result as OriginalResult,
|
AddPersonResult as OriginalResult,
|
||||||
SearchOptions,
|
SearchOptions,
|
||||||
} from "ChillPersonAssets/types";
|
} from "ChillPersonAssets/types";
|
||||||
|
|
||||||
@ -281,10 +274,7 @@ function setQuery(q: string) {
|
|||||||
loadSuggestions(suggested.results);
|
loadSuggestions(suggested.results);
|
||||||
})
|
})
|
||||||
.catch((error: DOMException) => {
|
.catch((error: DOMException) => {
|
||||||
if (
|
if (error instanceof DOMException && error.name === "AbortError") {
|
||||||
error instanceof DOMException &&
|
|
||||||
error.name === "AbortError"
|
|
||||||
) {
|
|
||||||
// Request was aborted, ignore
|
// Request was aborted, ignore
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user