Fix multiple css issues on Item card [SCI-9653] (#6608)

This commit is contained in:
wandji 2023-11-13 14:13:53 +01:00 committed by GitHub
parent 5878ed0c7c
commit 2e3ae5cc5c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
18 changed files with 165 additions and 132 deletions

View file

@ -187,7 +187,7 @@
<!-- NAVIGATION --> <!-- NAVIGATION -->
<div v-if="isShowing" ref="navigationRef" id="navigation" <div v-if="isShowing" ref="navigationRef" id="navigation"
class="flex item-end gap-x-4 min-w-[130px] min-h-[130px] h-fit sticky top-0 right-[24px] "> class="flex item-end gap-x-4 min-w-[130px] min-h-[130px] h-fit sticky top-0 right-[4px] ">
<scroll-spy :itemsToCreate="[ <scroll-spy :itemsToCreate="[
{ id: 'highlight-item-1', textId: 'text-item-1', labelAlias: 'information_label', label: 'information-label', sectionId: 'information-section' }, { id: 'highlight-item-1', textId: 'text-item-1', labelAlias: 'information_label', label: 'information-label', sectionId: 'information-section' },
{ id: 'highlight-item-2', textId: 'text-item-2', labelAlias: 'custom_columns_label', label: 'custom-columns-label', sectionId: 'custom-columns-section' }, { id: 'highlight-item-2', textId: 'text-item-2', labelAlias: 'custom_columns_label', label: 'custom-columns-label', sectionId: 'custom-columns-section' },

View file

@ -9,6 +9,7 @@
<div v-if="dateType === 'date'"> <div v-if="dateType === 'date'">
<div v-if="isEditing || values?.datetime" ref="edit"> <div v-if="isEditing || values?.datetime" ref="edit">
<DateTimePicker <DateTimePicker
:disabled="!canEdit"
@change="formatDateTime($event)" @change="formatDateTime($event)"
:selectorId="`DatePicker${colId}`" :selectorId="`DatePicker${colId}`"
:dateOnly="true" :dateOnly="true"
@ -16,7 +17,7 @@
:standAlone="true" :standAlone="true"
/> />
</div> </div>
<div v-else ref="view" > <div v-else ref="view" :class="{ 'text-sn-dark-grey': !canEdit, 'text-sn-grey': canEdit }" >
{{ i18n.t(`repositories.item_card.repository_date_value.${canEdit ? 'placeholder' : 'no_date'}`) }} {{ i18n.t(`repositories.item_card.repository_date_value.${canEdit ? 'placeholder' : 'no_date'}`) }}
</div> </div>
</div> </div>
@ -24,6 +25,7 @@
<div v-if="isEditing || (timeFrom?.datetime && timeTo?.datetime)" ref="edit" class="w-full flex align-center"> <div v-if="isEditing || (timeFrom?.datetime && timeTo?.datetime)" ref="edit" class="w-full flex align-center">
<div> <div>
<DateTimePicker <DateTimePicker
:disabled="!canEdit"
@change="formatDateTime($event, 'start_time')" @change="formatDateTime($event, 'start_time')"
:selectorId="`DatePickerStart${colId}`" :selectorId="`DatePickerStart${colId}`"
:dateOnly="true" :dateOnly="true"
@ -35,6 +37,7 @@
<span class="mr-3">-</span> <span class="mr-3">-</span>
<div> <div>
<DateTimePicker <DateTimePicker
:disabled="!canEdit"
@change="formatDateTime($event, 'end_time')" @change="formatDateTime($event, 'end_time')"
:selectorId="`DatePickerEnd${colId}`" :selectorId="`DatePickerEnd${colId}`"
:dateOnly="true" :dateOnly="true"
@ -44,13 +47,14 @@
/> />
</div> </div>
</div> </div>
<div v-else ref="view" > <div v-else ref="view" :class="{ 'text-sn-dark-grey': !canEdit, 'text-sn-grey': canEdit }" >
{{ i18n.t(`repositories.item_card.repository_date_range_value.${canEdit ? 'placeholder' : 'no_date_range'}`) }} {{ i18n.t(`repositories.item_card.repository_date_range_value.${canEdit ? 'placeholder' : 'no_date_range'}`) }}
</div> </div>
</div> </div>
<div v-if="dateType === 'dateTime'"> <div v-if="dateType === 'dateTime'">
<div v-if="isEditing || values?.datetime" ref="edit" class="w-full"> <div v-if="isEditing || values?.datetime" ref="edit" class="w-full">
<DateTimePicker <DateTimePicker
:disabled="!canEdit"
@change="formatDateTime" @change="formatDateTime"
:selectorId="`DatePicker${colId}`" :selectorId="`DatePicker${colId}`"
:defaultValue="dateValue(values?.datetime)" :defaultValue="dateValue(values?.datetime)"
@ -59,7 +63,7 @@
timeClassName="w-11" timeClassName="w-11"
/> />
</div> </div>
<div v-else ref="view" > <div v-else ref="view" :class="{ 'text-sn-dark-grey': !canEdit, 'text-sn-grey': canEdit }" >
{{ i18n.t(`repositories.item_card.repository_date_time_value.${canEdit ? 'placeholder' : 'no_date_time'}`) }} {{ i18n.t(`repositories.item_card.repository_date_time_value.${canEdit ? 'placeholder' : 'no_date_time'}`) }}
</div> </div>
</div> </div>
@ -67,6 +71,7 @@
<div v-if="isEditing || (timeFrom?.datetime && timeTo?.datetime)" ref="edit" class="w-full flex"> <div v-if="isEditing || (timeFrom?.datetime && timeTo?.datetime)" ref="edit" class="w-full flex">
<div> <div>
<DateTimePicker <DateTimePicker
:disabled="!canEdit"
@change="formatDateTime($event, 'start_time')" @change="formatDateTime($event, 'start_time')"
:selectorId="`DatePickerStart${colId}`" :selectorId="`DatePickerStart${colId}`"
:defaultValue="dateValue(timeFrom?.datetime)" :defaultValue="dateValue(timeFrom?.datetime)"
@ -80,6 +85,7 @@
<span class="mx-1">-</span> <span class="mx-1">-</span>
<div> <div>
<DateTimePicker <DateTimePicker
:disabled="!canEdit"
@change="formatDateTime($event, 'end_time')" @change="formatDateTime($event, 'end_time')"
:selectorId="`DatePickerEnd${colId}`" :selectorId="`DatePickerEnd${colId}`"
:defaultValue="dateValue(timeTo?.datetime)" :defaultValue="dateValue(timeTo?.datetime)"
@ -91,13 +97,14 @@
/> />
</div> </div>
</div> </div>
<div v-else ref="view" > <div v-else ref="view" :class="{ 'text-sn-dark-grey': !canEdit, 'text-sn-grey': canEdit }" >
{{ i18n.t(`repositories.item_card.repository_date_time_range_value.${canEdit ? 'placeholder' : 'no_date_time_range'}`) }} {{ i18n.t(`repositories.item_card.repository_date_time_range_value.${canEdit ? 'placeholder' : 'no_date_time_range'}`) }}
</div> </div>
</div> </div>
<div v-else-if="dateType === 'time'"> <div v-else-if="dateType === 'time'">
<div v-if="isEditing || values?.datetime" ref="edit"> <div v-if="isEditing || values?.datetime" ref="edit">
<DateTimePicker <DateTimePicker
:disabled="!canEdit"
@change="formatDateTime" @change="formatDateTime"
:selectorId="`DatePicker${colId}`" :selectorId="`DatePicker${colId}`"
:timeOnly="true" :timeOnly="true"
@ -106,7 +113,7 @@
timeClassName="w-11" timeClassName="w-11"
/> />
</div> </div>
<div v-else ref="view"> <div v-else ref="view" :class="{ 'text-sn-dark-grey': !canEdit, 'text-sn-grey': canEdit }">
{{ i18n.t(`repositories.item_card.repository_time_value.${ canEdit ? 'placeholder' : 'no_time'}`) }} {{ i18n.t(`repositories.item_card.repository_time_value.${ canEdit ? 'placeholder' : 'no_time'}`) }}
</div> </div>
</div> </div>
@ -114,6 +121,7 @@
<div v-if="isEditing || (timeFrom?.datetime && timeTo?.datetime)" ref="edit" class="w-full flex"> <div v-if="isEditing || (timeFrom?.datetime && timeTo?.datetime)" ref="edit" class="w-full flex">
<div> <div>
<DateTimePicker <DateTimePicker
:disabled="!canEdit"
@change="formatDateTime($event, 'start_time')" @change="formatDateTime($event, 'start_time')"
:selectorId="`DatePickerStart${colId}`" :selectorId="`DatePickerStart${colId}`"
:timeOnly="true" :timeOnly="true"
@ -125,6 +133,7 @@
<span class="mx-1">-</span> <span class="mx-1">-</span>
<div> <div>
<DateTimePicker <DateTimePicker
:disabled="!canEdit"
@change="formatDateTime($event, 'end_time')" @change="formatDateTime($event, 'end_time')"
:selectorId="`DatePickerEnd${colId}`" :selectorId="`DatePickerEnd${colId}`"
:timeOnly="true" :timeOnly="true"
@ -134,7 +143,7 @@
/> />
</div> </div>
</div> </div>
<div v-else ref="view"> <div v-else ref="view" :class="{ 'text-sn-dark-grey': !canEdit, 'text-sn-grey': canEdit }">
{{ i18n.t(`repositories.item_card.repository_time_range_value.${canEdit ? 'placeholder' : 'no_time_range'}`) }} {{ i18n.t(`repositories.item_card.repository_time_range_value.${canEdit ? 'placeholder' : 'no_time_range'}`) }}
</div> </div>
</div> </div>
@ -191,7 +200,7 @@
}, },
computed: { computed: {
editableClassName() { editableClassName() {
const className = 'border-solid border-[1px] p-2 sci-cursor-edit' const className = 'border-solid border-[1px] py-2 px-3 sci-cursor-edit'
if (this.canEdit && this.errorMessage) return `${className} border-sn-delete-red`; if (this.canEdit && this.errorMessage) return `${className} border-sn-delete-red`;
if (this.canEdit && this.isEditing) return `${className} border-sn-science-blue`; if (this.canEdit && this.isEditing) return `${className} border-sn-science-blue`;
if (this.canEdit) return `${className} border-sn-light-grey hover:border-sn-sleepy-grey`; if (this.canEdit) return `${className} border-sn-light-grey hover:border-sn-sleepy-grey`;

View file

@ -35,7 +35,8 @@
</div> </div>
</div> </div>
</div> </div>
<div v-else-if="!error" class="flex flex-row items-center text-sn-grey font-inter text-sm font-normal leading-5 justify-between"> <div v-else-if="!error" class="flex flex-row items-center font-inter text-sm font-normal leading-5 justify-between"
:class="{ 'text-sn-dark-grey': !canEdit, 'text-sn-grey': canEdit }">
{{ i18n.t(`repositories.item_card.repository_asset_value.${canEdit ? 'placeholder' : 'no_asset'}`) }} {{ i18n.t(`repositories.item_card.repository_asset_value.${canEdit ? 'placeholder' : 'no_asset'}`) }}
</div> </div>
</div> </div>

View file

@ -5,7 +5,7 @@
</div> </div>
<div v-if="checklistItems.length > 0"> <div v-if="checklistItems.length > 0">
<checklist-select <checklist-select
v-if="permissions?.can_manage && !inArchivedRepositoryRow" v-if="canEdit"
@change="changeSelected" @change="changeSelected"
@update="update" @update="update"
:initialSelectedValues="colVal?.map(item => item.value)" :initialSelectedValues="colVal?.map(item => item.value)"
@ -15,6 +15,8 @@
:options="checklistItems" :options="checklistItems"
:placeholder="i18n.t('repositories.item_card.dropdown_placeholder')" :placeholder="i18n.t('repositories.item_card.dropdown_placeholder')"
:no-options-placeholder="i18n.t('repositories.item_card.dropdown_placeholder')" :no-options-placeholder="i18n.t('repositories.item_card.dropdown_placeholder')"
className="h-[38px] !pl-3"
optionsClassName="max-h-[300px]"
></checklist-select> ></checklist-select>
<div v-else <div v-else
class="text-sn-dark-grey font-inter text-sm font-normal leading-5 w-[370px] overflow-x-auto flex flex-wrap gap-1"> class="text-sn-dark-grey font-inter text-sm font-normal leading-5 w-[370px] overflow-x-auto flex flex-wrap gap-1">
@ -52,9 +54,8 @@ export default {
colId: Number, colId: Number,
colName: String, colName: String,
colVal: Array, colVal: Array,
permissions: null,
optionsPath: String, optionsPath: String,
inArchivedRepositoryRow: Boolean, canEdit: Boolean
}, },
data() { data() {
return { return {

View file

@ -17,6 +17,8 @@
:placeholder="i18n.t('repositories.item_card.dropdown_placeholder')" :placeholder="i18n.t('repositories.item_card.dropdown_placeholder')"
:no-options-placeholder="i18n.t('repositories.item_card.dropdown_placeholder')" :no-options-placeholder="i18n.t('repositories.item_card.dropdown_placeholder')"
:searchPlaceholder="i18n.t('repositories.item_card.dropdown_placeholder')" :searchPlaceholder="i18n.t('repositories.item_card.dropdown_placeholder')"
className="h-[38px] !pl-3"
optionsClassName="max-h-[300px]"
></select-search> ></select-search>
<div v-else-if="text" <div v-else-if="text"
class="text-sn-dark-grey font-inter text-sm font-normal leading-5" class="text-sn-dark-grey font-inter text-sm font-normal leading-5"

View file

@ -13,9 +13,9 @@
}} }}
</div> </div>
</div> </div>
<div v-if="canEdit"> <div v-if="canEdit" class="w-full">
<text-area :initialValue="(colVal)?.toLocaleString('fullwide', {useGrouping:false}) || ''" <text-area :initialValue="(colVal)?.toLocaleString('fullwide', {useGrouping:false}) || ''"
:noContentPlaceholder="noContentPlaceholder" :noContentPlaceholder="i18n.t('repositories.item_card.repository_number_value.placeholder')"
:placeholder="i18n.t('repositories.item_card.repository_number_value.placeholder')" :placeholder="i18n.t('repositories.item_card.repository_number_value.placeholder')"
:decimals="decimals" :decimals="decimals"
:isNumber="true" :isNumber="true"
@ -23,7 +23,8 @@
:expandable="expandable" :expandable="expandable"
:collapsed="collapsed" :collapsed="collapsed"
@toggleExpandableState="toggleExpandableState" @toggleExpandableState="toggleExpandableState"
@update="update" /> @update="update"
className="px-3"/>
</div> </div>
<div v-else-if="colVal" <div v-else-if="colVal"
ref="numberRef" ref="numberRef"
@ -64,18 +65,12 @@ export default {
colName: String, colName: String,
colVal: Number, colVal: Number,
permissions: null, permissions: null,
inArchivedRepositoryRow: Boolean, canEdit: { type: Boolean, defaul: false}
}, },
created() { created() {
// constants // constants
this.noContentPlaceholder = this.i18n.t("repositories.item_card.repository_number_value.no_number");
this.decimals = Number(document.getElementById(`${this.colId}`).dataset['metadataDecimals']) || 0; this.decimals = Number(document.getElementById(`${this.colId}`).dataset['metadataDecimals']) || 0;
}, },
computed: {
canEdit() {
return this.permissions?.can_manage && !this.inArchivedRepositoryRow;
}
},
methods: { methods: {
toggleCollapse() { toggleCollapse() {
if (!this.expandable) return; if (!this.expandable) return;

View file

@ -17,6 +17,8 @@
:placeholder="i18n.t('repositories.item_card.dropdown_placeholder')" :placeholder="i18n.t('repositories.item_card.dropdown_placeholder')"
:no-options-placeholder="i18n.t('repositories.item_card.dropdown_placeholder')" :no-options-placeholder="i18n.t('repositories.item_card.dropdown_placeholder')"
:searchPlaceholder="i18n.t('repositories.item_card.dropdown_placeholder')" :searchPlaceholder="i18n.t('repositories.item_card.dropdown_placeholder')"
className="h-[38px] !pl-3"
optionsClassName="max-h-[300px]"
></select-search> ></select-search>
<div v-else-if="status && icon" <div v-else-if="status && icon"
class="flex flex-row items-center text-sn-dark-grey font-inter text-sm font-normal leading-5 gap-1.5"> class="flex flex-row items-center text-sn-dark-grey font-inter text-sm font-normal leading-5 gap-1.5">

View file

@ -18,7 +18,7 @@
<div v-if="values?.stock_formatted" :data-manage-stock-url="values?.stock_url" class="text-sn-dark-grey font-inter text-sm font-normal leading-5 stock-value"> <div v-if="values?.stock_formatted" :data-manage-stock-url="values?.stock_url" class="text-sn-dark-grey font-inter text-sm font-normal leading-5 stock-value">
{{ values.stock_formatted }} {{ values.stock_formatted }}
</div> </div>
<div v-else class="text-sn-dark-grey font-inter text-sm font-normal leading-5 stock-value"> <div v-else class="font-inter text-sm font-normal leading-5" :class="{ 'text-sn-dark-grey': !canEdit, 'text-sn-grey': canEdit }">
{{ i18n.t(`repositories.item_card.repository_stock_value.${canEdit ? 'placeholder' : 'no_stock'}`) }} {{ i18n.t(`repositories.item_card.repository_stock_value.${canEdit ? 'placeholder' : 'no_stock'}`) }}
</div> </div>
<span class="absolute right-2 reminder" :class="{ 'top-1.5': canEdit, 'top-0': !canEdit, hidden: !values?.reminder }"> <span class="absolute right-2 reminder" :class="{ 'top-1.5': canEdit, 'top-0': !canEdit, hidden: !values?.reminder }">

View file

@ -16,7 +16,7 @@
<div v-if="canEdit"> <div v-if="canEdit">
<text-area :initialValue="colVal?.edit" <text-area :initialValue="colVal?.edit"
:noContentPlaceholder="noContentPlaceholder" :noContentPlaceholder="i18n.t('repositories.item_card.repository_text_value.placeholder')"
:placeholder="i18n.t('repositories.item_card.repository_text_value.placeholder')" :placeholder="i18n.t('repositories.item_card.repository_text_value.placeholder')"
:unEditableRef="`textRef`" :unEditableRef="`textRef`"
:smartAnnotation="true" :smartAnnotation="true"
@ -24,7 +24,8 @@
:expandable="expandable" :expandable="expandable"
:collapsed="collapsed" :collapsed="collapsed"
@toggleExpandableState="toggleExpandableState" @toggleExpandableState="toggleExpandableState"
@update="update" /> @update="update"
className="px-3" />
</div> </div>
<div v-else-if="colVal?.edit" <div v-else-if="colVal?.edit"
ref="textRef" ref="textRef"
@ -65,18 +66,12 @@ export default {
colId: Number, colId: Number,
colName: String, colName: String,
colVal: Object, colVal: Object,
permissions: null, canEdit: { type: Boolean, default: false }
inArchivedRepositoryRow: Boolean,
}, },
created() { created() {
// constants // constants
this.noContentPlaceholder = this.i18n.t("repositories.item_card.repository_text_value.no_text"); this.noContentPlaceholder = this.i18n.t("repositories.item_card.repository_text_value.no_text");
}, },
computed: {
canEdit() {
return this.permissions?.can_manage && !this.inArchivedRepositoryRow;
}
},
methods: { methods: {
toggleCollapse() { toggleCollapse() {
if (!this.expandable) return; if (!this.expandable) return;

View file

@ -2,23 +2,26 @@
<textarea v-if="editing" <textarea v-if="editing"
ref="textareaRef" ref="textareaRef"
class="leading-5 inline-block outline-none border-solid font-normal border-[1px] box-content class="leading-5 inline-block outline-none border-solid font-normal border-[1px] box-content
overflow-x-hidden overflow-y-auto resize-none rounded px-4 py-2 w-[calc(100%-2rem)] overflow-x-hidden overflow-y-auto resize-none rounded py-2 w-[calc(100%-1.5rem)]
border-sn-science-blue" border-sn-science-blue"
:class="{ :class="{
'max-h-[4rem]': collapsed, 'max-h-[4rem]': collapsed,
'max-h-[40rem]': !collapsed 'max-h-[40rem]': !collapsed,
[className]: true
}" }"
:placeholder="placeholder" :placeholder="placeholder"
v-model="value" v-model="value"
@keydown="handleKeydown" @keydown="handleKeydown"
@blur="handleBlur" /> @blur="handleBlur"></textarea>
<div v-else <div v-else
:ref="unEditableRef" :ref="unEditableRef"
class="grid box-content sci-cursor-edit font-normal border-solid px-4 py-2 border-sn-light-grey rounded class="grid box-content sci-cursor-edit font-normal border-solid py-2 border-sn-light-grey rounded
leading-5 border outline-none hover:border-sn-sleepy-grey overflow-y-auto whitespace-pre-line leading-5 border outline-none hover:border-sn-sleepy-grey overflow-y-auto whitespace-pre-line"
w-[calc(100%-2rem)]"
:class="{ 'max-h-[4rem]': collapsed, :class="{ 'max-h-[4rem]': collapsed,
'max-h-[40rem]': !collapsed, }" 'max-h-[40rem]': !collapsed,
[className]: true,
'text-sn-dark-grey': value, 'text-sn-grey': !value
}"
@click="enableEdit"> @click="enableEdit">
<span v-if="smartAnnotation" <span v-if="smartAnnotation"
v-html="sa_value || noContentPlaceholder" v-html="sa_value || noContentPlaceholder"
@ -47,6 +50,7 @@ export default {
unEditableRef: { type: String, required: true }, unEditableRef: { type: String, required: true },
smartAnnotation: { type: Boolean, default: false }, smartAnnotation: { type: Boolean, default: false },
sa_value: { type: String }, sa_value: { type: String },
className: { type: String, default: false }
}, },
mounted() { mounted() {
this.value = this.initialValue; this.value = this.initialValue;

View file

@ -1,35 +1,31 @@
<template> <template>
<div class="w-full relative" ref="container" v-click-outside="{ handler: 'close', exclude: [] }"> <div class="w-full relative" ref="container" v-click-outside="{ handler: 'close', exclude: ['optionsContainer'] }">
<button ref="focusElement" <button ref="focusElement"
class="btn flex justify-between items-center w-full outline-none border-[1px] bg-white rounded p-2 pl-4 class="btn flex justify-between items-center w-full outline-none border-[1px] bg-white rounded p-2
font-inter text-sm font-normal leading-5" font-inter text-sm font-normal leading-5"
:class="{ :class="{
'sci-cursor-edit': !isOpen && withEditCursor, 'sci-cursor-edit': !isOpen && withEditCursor,
'border-sn-light-grey hover:border-sn-sleepy-grey': !isOpen, 'border-sn-light-grey hover:border-sn-sleepy-grey': !isOpen,
'border-sn-science-blue': isOpen 'border-sn-science-blue': isOpen,
'text-sn-grey': !valueLabel,
[className]: true
}" }"
:disabled="disabled" :disabled="disabled"
@click="toggle"> @click="toggle">
<span>{{ valueLabel }}</span> <span>{{ valueLabel || this.placeholder || this.i18n.t('general.select') }}</span>
<i class="sn-icon" :class="{ 'sn-icon-down': !isOpen, 'sn-icon-up': isOpen}"></i> <i class="sn-icon" :class="{ 'sn-icon-down': !isOpen, 'sn-icon-up': isOpen}"></i>
</button> </button>
<perfect-scrollbar ref="optionsContainer" <div :style="optionPositionStyle" class="py-2.5 z-10 bg-white rounded border-[1px] border-sn-light-grey shadow-sn-menu-sm" :class="{ 'hidden': !isOpen }">
:style="optionPositionStyle" <div v-if="withButtons" class="px-2.5">
class="relative scroll-container p-2.5 pt-0 z-10 bg-white rounded border-[1px] border-sn-light-grey shadow-flyout-shadow max-h-[25rem]" <div class="flex gap-2 pl-2 pb-2.5 justify-start items-center w-[calc(100%-10px)]">
:class="{ <div class="btn btn-light !text-xs h-[30px] px-0 active:bg-sn-super-light-blue"
'block': isOpen,
'hidden': !isOpen
}">
<div v-if="withButtons" class="sticky z-10 top-0 bg-white">
<div class="pb-1 pt-2.5 rounded flex gap-1 justify-start items-center">
<div class="btn btn-light !text-xs active:bg-sn-super-light-blue"
@click="selectedValues = []" @click="selectedValues = []"
:class="{ :class="{
'disabled cursor-default': !selectedValues.length, 'disabled cursor-default': !selectedValues.length,
'cursor-pointer': selectedValues.length 'cursor-pointer': selectedValues.length
}" }"
>{{ i18n.t('general.clear') }}</div> >{{ i18n.t('general.clear') }}</div>
<div class="btn btn-light !text-xs active:bg-sn-super-light-blue" <div class="btn btn-light !text-xs h-[30px] px-0 active:bg-sn-super-light-blue"
@click="selectedValues = options.map(option => option.id)" @click="selectedValues = options.map(option => option.id)"
:class="{ :class="{
'disabled cursor-default': options.length === selectedValues.length, 'disabled cursor-default': options.length === selectedValues.length,
@ -38,15 +34,21 @@
</div> </div>
</div> </div>
</div> </div>
<perfect-scrollbar ref="optionsContainer"
class="relative scroll-container px-2.5 pt-0"
:class="{
'block': isOpen,
[optionsClassName]: true
}">
<div v-if="options.length" class="flex flex-col gap-[1px]"> <div v-if="options.length" class="flex flex-col gap-[1px]">
<div v-for="option in options" <div v-for="option in options"
:key="option.id" :key="option.id"
class="p-3 rounded hover:bg-sn-super-light-grey cursor-pointer flex gap-1 justify-start"> class="px-3 py-2 rounded hover:bg-sn-super-light-grey cursor-pointer flex gap-1 justify-start items-center">
<div class="sci-checkbox-container"> <div class="sci-checkbox-container">
<input v-model="selectedValues" :value="option.id" :id="option.id" type="checkbox" class="sci-checkbox project-card-selector mr-1"> <input v-model="selectedValues" :value="option.id" :id="option.id" type="checkbox" class="sci-checkbox project-card-selector">
<label :for="option.id" class="sci-checkbox-label"></label> <label :for="option.id" class="sci-checkbox-label"></label>
</div> </div>
<span class="text-ellipsis overflow-hidden max-h-[4rem]">{{ option.label }}</span> <span class="text-ellipsis overflow-hidden max-h-[4rem] ml-1">{{ option.label }}</span>
</div> </div>
</div> </div>
<template v-else> <template v-else>
@ -58,10 +60,12 @@
</template> </template>
</perfect-scrollbar> </perfect-scrollbar>
</div> </div>
</div>
</template> </template>
<script> <script>
import PerfectScrollbar from 'vue2-perfect-scrollbar'; import PerfectScrollbar from 'vue2-perfect-scrollbar';
import outsideClick from '../../packs/vue/directives/outside_click';
export default { export default {
name: 'ChecklistSelect', name: 'ChecklistSelect',
@ -73,7 +77,12 @@
options: { type: Array, default: () => [] }, options: { type: Array, default: () => [] },
placeholder: { type: String }, placeholder: { type: String },
noOptionsPlaceholder: { type: String }, noOptionsPlaceholder: { type: String },
disabled: { type: Boolean, default: false } disabled: { type: Boolean, default: false },
className: { type: String, default: '' },
optionsClassName: { type: String, default: '' }
},
directives: {
'click-outside': outsideClick
}, },
data() { data() {
return { return {
@ -87,9 +96,7 @@
}, },
computed: { computed: {
valueLabel() { valueLabel() {
if (!this.selectedValues.length) { if (!this.selectedValues.length) return
return (this.placeholder || this.i18n.t('general.select'));
}
return `${this.selectedValues.length} ${this.i18n.t('general.selected')}`; return `${this.selectedValues.length} ${this.i18n.t('general.selected')}`;
} }

View file

@ -16,6 +16,7 @@
class='inline-block m-0 p-0 w-full border-none shadow-none outline-none' class='inline-block m-0 p-0 w-full border-none shadow-none outline-none'
:id="this.selectorId" :id="this.selectorId"
:placeholder="placeholder || 'dd/mm/yyyy'" :placeholder="placeholder || 'dd/mm/yyyy'"
:disabled="disabled"
/> />
</div> </div>
</template> </template>
@ -31,7 +32,8 @@
useCurrent: { type: Boolean, default: true }, useCurrent: { type: Boolean, default: true },
defaultValue: { type: Date, default: null }, defaultValue: { type: Date, default: null },
standAlone: { type: Boolean, default: false, required: false }, standAlone: { type: Boolean, default: false, required: false },
className: { type: String, default: '' } className: { type: String, default: '' },
disabled: { type: Boolean, default: false }
}, },
mounted() { mounted() {
$("#" + this.selectorId).datetimepicker( $("#" + this.selectorId).datetimepicker(

View file

@ -7,6 +7,7 @@
:defaultValue="defaultValue" :defaultValue="defaultValue"
:standAlone="standAlone" :standAlone="standAlone"
:className="dateClassName" :className="dateClassName"
:disabled="disabled"
/> />
<TimePicker v-if="!dateOnly" <TimePicker v-if="!dateOnly"
@change="updateTime" @change="updateTime"
@ -15,6 +16,7 @@
:defaultValue="getTime(defaultValue)" :defaultValue="getTime(defaultValue)"
:standAlone="standAlone" :standAlone="standAlone"
:className="timeClassName" :className="timeClassName"
:disabled="disabled"
/> />
</div> </div>
</template> </template>
@ -33,7 +35,8 @@
placeholder: { type: String }, placeholder: { type: String },
standAlone: { type: Boolean, default: false, required: false }, standAlone: { type: Boolean, default: false, required: false },
dateClassName: { type: String, default: '' }, dateClassName: { type: String, default: '' },
timeClassName: { type: String, default: '' } timeClassName: { type: String, default: '' },
disabled: { type: Boolean, default: false }
}, },
data() { data() {
return { return {

View file

@ -4,8 +4,9 @@
<input type="text" <input type="text"
v-if="singleLine" v-if="singleLine"
ref="input" ref="input"
class="inline-block leading-5 outline-none pl-0 py-1 border-0 border-solid border-y w-full border-t-transparent" class="inline-block leading-5 outline-none pl-0 border-0 border-solid border-y w-full border-t-transparent"
:class="{ :class="{
'py-1': !singleLine,
'inline-edit-placeholder text-sn-grey caret-black': isBlank, 'inline-edit-placeholder text-sn-grey caret-black': isBlank,
'border-b-sn-delete-red': error, 'border-b-sn-delete-red': error,
'border-b-sn-science-blue': !error, 'border-b-sn-science-blue': !error,
@ -33,8 +34,8 @@
<div <div
v-else v-else
ref="view" ref="view"
class="grid sci-cursor-edit leading-5 border-0 py-1 outline-none border-solid border-y border-transparent" class="grid sci-cursor-edit leading-5 border-0 outline-none border-solid border-y border-transparent"
:class="{ 'text-sn-grey font-normal': isBlank, 'whitespace-pre-line': !singleLine }" :class="{ 'text-sn-grey font-normal': isBlank, 'whitespace-pre-line py-1': !singleLine }"
@click="enableEdit($event)" @click="enableEdit($event)"
> >
<span :class="{'truncate': singleLine }" v-if="smartAnnotation" v-html="sa_value || placeholder" ></span> <span :class="{'truncate': singleLine }" v-if="smartAnnotation" v-html="sa_value || placeholder" ></span>

View file

@ -17,11 +17,8 @@
</button> </button>
<i class="sn-icon" :class="{ 'sn-icon-down': !isOpen, 'sn-icon-up': isOpen}"></i> <i class="sn-icon" :class="{ 'sn-icon-down': !isOpen, 'sn-icon-up': isOpen}"></i>
</slot> </slot>
<perfect-scrollbar ref="optionsContainer" <div :style="optionPositionStyle" class="py-2.5 bg-white z-10 shadow-sn-menu-sm" :class="{ 'hidden': !isOpen }">
:style="optionPositionStyle" <div v-if="withClearButton" class="px-2 pb-2.5">
class="sn-select__options scroll-container p-2.5 pt-0 block"
>
<div v-if="withClearButton" class="sticky z-10 top-0 pt-2.5 bg-white">
<div @mousedown.prevent.stop="setValue(null)" <div @mousedown.prevent.stop="setValue(null)"
class="btn btn-light !text-xs active:bg-sn-super-light-blue" class="btn btn-light !text-xs active:bg-sn-super-light-blue"
:class="{ :class="{
@ -31,12 +28,17 @@
{{ i18n.t('general.clear') }} {{ i18n.t('general.clear') }}
</div> </div>
</div> </div>
<perfect-scrollbar ref="optionsContainer"
class="sn-select__options !relative !top-0 !left-[-1px] !shadow-none scroll-container px-2.5 pt-0 block"
:class="{ [optionsClassName]: true }"
>
<div v-if="options.length" class="flex flex-col gap-[1px]"> <div v-if="options.length" class="flex flex-col gap-[1px]">
<div <div
v-for="option in options" v-for="option in options"
:key="option[0]" :key="option[0]"
@mousedown.prevent.stop="setValue(option[0])" @mousedown.prevent.stop="setValue(option[0])"
class="sn-select__option p-3 rounded" class="sn-select__option p-3 rounded shadow-none"
:title="option[1]" :title="option[1]"
:class="{ :class="{
'select__option-placeholder': option[2], 'select__option-placeholder': option[2],
@ -55,6 +57,7 @@
</template> </template>
</perfect-scrollbar> </perfect-scrollbar>
</div> </div>
</div>
</template> </template>
<script> <script>
import PerfectScrollbar from 'vue2-perfect-scrollbar'; import PerfectScrollbar from 'vue2-perfect-scrollbar';
@ -71,6 +74,7 @@
placeholder: { type: String }, placeholder: { type: String },
noOptionsPlaceholder: { type: String }, noOptionsPlaceholder: { type: String },
className: { type: String, default: '' }, className: { type: String, default: '' },
optionsClassName: { type: String, default: '' },
disabled: { type: Boolean, default: false } disabled: { type: Boolean, default: false }
}, },
directives: { directives: {

View file

@ -1,6 +1,8 @@
<template> <template>
<Select <Select
class="sn-select--search" class="sn-select sn-select--search"
:className="className"
:optionsClassName="optionsClassName"
:withEditCursor="withEditCursor" :withEditCursor="withEditCursor"
:withClearButton="withClearButton" :withClearButton="withClearButton"
:value="value" :value="value"
@ -34,7 +36,9 @@
searchPlaceholder: { type: String }, searchPlaceholder: { type: String },
noOptionsPlaceholder: { type: String }, noOptionsPlaceholder: { type: String },
disabled: { type: Boolean }, disabled: { type: Boolean },
isLoading: { type: Boolean, default: false } isLoading: { type: Boolean, default: false },
className: { type: String, default: '' },
optionsClassName: { type: String, default: '' }
}, },
components: { Select }, components: { Select },
data() { data() {

View file

@ -15,6 +15,7 @@
:id="this.selectorId" :id="this.selectorId"
type="text" type="text"
data-mask-type="time" data-mask-type="time"
:disabled="disabled"
v-model="value" v-model="value"
placeholder="HH:mm" placeholder="HH:mm"
/> />
@ -28,7 +29,8 @@
selectorId: { type: String, required: true }, selectorId: { type: String, required: true },
defaultValue: { type: String, required: false }, defaultValue: { type: String, required: false },
standAlone: { type: Boolean, default: true, required: false }, standAlone: { type: Boolean, default: true, required: false },
className: { type: String, default: '', required: false } className: { type: String, default: '', required: false },
disabled: { type: Boolean, default: false }
}, },
data() { data() {
return { return {

View file

@ -60,6 +60,7 @@ module.exports = {
}, },
boxShadow: { boxShadow: {
'flyout-shadow': '0px 1px 4px rgba(35, 31, 32, 0.15)', 'flyout-shadow': '0px 1px 4px rgba(35, 31, 32, 0.15)',
'sn-menu-sm': '0px 16px 32px 0px rgba(16, 24, 40, 0.07)',
}, },
transitionTimingFunction: { transitionTimingFunction: {
sharp: 'cubic-bezier(.4, 0, .6, 1)', sharp: 'cubic-bezier(.4, 0, .6, 1)',