Skip to content

Commit

Permalink
Apply eslint
Browse files Browse the repository at this point in the history
+ one attribute per line
+ removed unecessary props from return
+ attribute ordering
  • Loading branch information
Severino committed Oct 24, 2023
1 parent 880d29c commit 0063830
Show file tree
Hide file tree
Showing 19 changed files with 744 additions and 379 deletions.
217 changes: 143 additions & 74 deletions resources/js/components/AttributeList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,55 +8,120 @@
:disabled="disableDrag"
:group="group"
:move="handleMove"
@change="handleUpdate">
<template #item="{element, index}">
<div class="mb-3" :class="clFromMetadata(element)" @mouseenter="onEnter(index)" @mouseleave="onLeave(index)" v-if="!state.hiddenAttributeList[element.id] || showHidden">
<div class="row" :class="addModerationStateClasses(element.id)">
<label
class="col-form-label col-md-3 d-flex flex-row justify-content-between text-break"
v-if="!state.hideLabels"
:for="`attr-${element.id}`"
:class="attributeClasses(element)">
<div v-show="!!state.hoverStates[index]" class="btn-fab-list">
<button v-show="hasEmitter('onReorderList')" class="reorder-handle btn btn-outline-secondary btn-fab rounded-circle" data-bs-toggle="popover" :data-content="t('global.resort')" data-trigger="hover" data-placement="bottom">
<i class="fas fa-fw fa-sort"></i>
</button>
<button v-show="hasEmitter('onEditElement')" class="btn btn-outline-info btn-fab rounded-circle" @click="onEditHandler(element)" data-bs-toggle="popover" :data-content="t('global.edit')" data-trigger="hover" data-placement="bottom">
<i class="fas fa-fw fa-xs fa-edit" style="vertical-align: 0;"></i>
</button>
<button v-show="hasEmitter('onRemoveElement')" class="btn btn-outline-danger btn-fab rounded-circle" @click="onRemoveHandler(element)" data-bs-toggle="popover" :data-content="t('global.remove')" data-trigger="hover" data-placement="bottom">
<i class="fas fa-fw fa-xs fa-times" style="vertical-align: 0;"></i>
</button>
<button v-show="hasEmitter('onDeleteElement')" class="btn btn-outline-danger btn-fab rounded-circle" @click="onDeleteHandler(element)" data-bs-toggle="popover" :data-content="t('global.delete')" data-trigger="hover" data-placement="bottom">
<i class="fas fa-fw fa-xs fa-trash" style="vertical-align: 0;"></i>
</button>
</div>
<span class="text-end col" v-if="!element.is_system">
{{ translateConcept(element.thesaurus_url) }}:
@change="handleUpdate"
>
<template #item="{element, index}">
<div
v-if="!state.hiddenAttributeList[element.id] || showHidden"
class="mb-3"
:class="clFromMetadata(element)"
@mouseenter="onEnter(index)"
@mouseleave="onLeave(index)"
>
<div
class="row"
:class="addModerationStateClasses(element.id)"
>
<label
v-if="!state.hideLabels"
class="col-form-label col-md-3 d-flex flex-row justify-content-between text-break"
:for="`attr-${element.id}`"
:class="attributeClasses(element)"
>
<div
v-show="!!state.hoverStates[index]"
class="btn-fab-list"
>
<button
v-show="hasEmitter('onReorderList')"
class="reorder-handle btn btn-outline-secondary btn-fab rounded-circle"
data-bs-toggle="popover"
:data-content="t('global.resort')"
data-trigger="hover"
data-placement="bottom"
>
<i class="fas fa-fw fa-sort" />
</button>
<button
v-show="hasEmitter('onEditElement')"
class="btn btn-outline-info btn-fab rounded-circle"
data-bs-toggle="popover"
:data-content="t('global.edit')"
data-trigger="hover"
data-placement="bottom"
@click="onEditHandler(element)"
>
<i
class="fas fa-fw fa-xs fa-edit"
style="vertical-align: 0;"
/>
</button>
<button
v-show="hasEmitter('onRemoveElement')"
class="btn btn-outline-danger btn-fab rounded-circle"
data-bs-toggle="popover"
:data-content="t('global.remove')"
data-trigger="hover"
data-placement="bottom"
@click="onRemoveHandler(element)"
>
<i
class="fas fa-fw fa-xs fa-times"
style="vertical-align: 0;"
/>
</button>
<button
v-show="hasEmitter('onDeleteElement')"
class="btn btn-outline-danger btn-fab rounded-circle"
data-bs-toggle="popover"
:data-content="t('global.delete')"
data-trigger="hover"
data-placement="bottom"
@click="onDeleteHandler(element)"
>
<i
class="fas fa-fw fa-xs fa-trash"
style="vertical-align: 0;"
/>
</button>
</div>
<span
v-if="!element.is_system"
class="text-end col"
>
{{ translateConcept(element.thesaurus_url) }}:
</span>
<sup
v-if="hasEmitter('onMetadata')"
class="clickable"
@click="onMetadataHandler(element)"
>
<span :class="getCertaintyClass(state.attributeValues[element.id].certainty, 'text')">
<i class="fas fa-fw fa-exclamation" />
</span>
<span v-if="state.attributeValues[element.id].comments_count > 0">
<i class="fas fa-fw fa-comment" />
</span>
<span v-if="metadataAddon(element.thesaurus_url)">
<i class="fas fa-fw fa-bookmark" />
</span>
<sup class="clickable" v-if="hasEmitter('onMetadata')" @click="onMetadataHandler(element)">
<span :class="getCertaintyClass(state.attributeValues[element.id].certainty, 'text')">
<i class="fas fa-fw fa-exclamation"></i>
</span>
<span v-if="state.attributeValues[element.id].comments_count > 0">
<i class="fas fa-fw fa-comment"></i>
</span>
<span v-if="metadataAddon(element.thesaurus_url)">
<i class="fas fa-fw fa-bookmark"></i>
</span>
</sup>
<sup v-if="hasEmitter('onEditElement') && !!element.pivot.depends_on" class="font-size-50">
<i class="fas fa-fw fa-circle text-warning"></i>
</sup>
</label>
<div :class="expandedClasses(index)">
<string-attribute
v-if="element.datatype == 'string'"
:ref="el => setRef(el, element.id)"
:disabled="element.isDisabled || state.hiddenAttributeList[element.id] || isDisabledInModeration(element.id)"
:name="`attr-${element.id}`"
:value="state.attributeValues[element.id].value"
@change="e => updateDirtyState(e, element.id)" />
</sup>
<sup
v-if="hasEmitter('onEditElement') && !!element.pivot.depends_on"
class="font-size-50"
>
<i class="fas fa-fw fa-circle text-warning" />
</sup>
</label>
<div :class="expandedClasses(index)">
<string-attribute
v-if="element.datatype == 'string'"
:ref="el => setRef(el, element.id)"
:disabled="element.isDisabled || state.hiddenAttributeList[element.id] || isDisabledInModeration(element.id)"
:name="`attr-${element.id}`"
:value="state.attributeValues[element.id].value"
@change="e => updateDirtyState(e, element.id)"
/>

<stringfield-attribute
v-else-if="element.datatype == 'stringf'"
Expand Down Expand Up @@ -182,14 +247,16 @@
@change="e => updateDirtyState(e, element.id)"
/>

<entity-attribute v-else-if="element.datatype == 'entity' || element.datatype == 'entity-mc'"
:ref="el => setRef(el, element.id)"
:disabled="element.isDisabled || state.hiddenAttributeList[element.id] || isDisabledInModeration(element.id)"
:name="`attr-${element.id}`"
:multiple="element.datatype == 'entity-mc'"
:hide-link="state.hideEntityLink"
:value="convertEntityValue(state.attributeValues[element.id], element.datatype == 'entity-mc')"
@change="e => updateDirtyState(e, element.id)" />
<entity-attribute
v-else-if="element.datatype == 'entity' || element.datatype == 'entity-mc'"
:ref="el => setRef(el, element.id)"
:disabled="element.isDisabled || state.hiddenAttributeList[element.id] || isDisabledInModeration(element.id)"
:name="`attr-${element.id}`"
:multiple="element.datatype == 'entity-mc'"
:hide-link="state.hideEntityLink"
:value="convertEntityValue(state.attributeValues[element.id], element.datatype == 'entity-mc')"
@change="e => updateDirtyState(e, element.id)"
/>

<date-attribute
v-else-if="element.datatype == 'date'"
Expand Down Expand Up @@ -233,25 +300,27 @@
:title="getSeparatorTitle(element)"
/>

<default-attribute
v-else
:ref="el => setRef(el, element.id)"
:disabled="element.isDisabled || state.hiddenAttributeList[element.id] || isDisabledInModeration(element.id)"
:name="`attr-${element.id}`"
:value="state.attributeValues[element.id].value"
@change="e => updateDirtyState(e, element.id)" />

<attribute-moderation-panel v-if="isInModeration(element.id)"
:element="element"
:value="state.attributeValues[element.id]"
@toggle-data="e => toggleAttributeValue(element.id)"
@moderate="e => handleModeration(element.id, e)"
@edit="e => handleEditModeration(element.id, e)"
/>
</div>
<default-attribute
v-else
:ref="el => setRef(el, element.id)"
:disabled="element.isDisabled || state.hiddenAttributeList[element.id] || isDisabledInModeration(element.id)"
:name="`attr-${element.id}`"
:value="state.attributeValues[element.id].value"
@change="e => updateDirtyState(e, element.id)"
/>

<attribute-moderation-panel
v-if="isInModeration(element.id)"
:element="element"
:value="state.attributeValues[element.id]"
@toggle-data="e => toggleAttributeValue(element.id)"
@moderate="e => handleModeration(element.id, e)"
@edit="e => handleEditModeration(element.id, e)"
/>
</div>
</div>
</template>
</div>
</template>
</draggable>
</template>

Expand Down Expand Up @@ -375,7 +444,7 @@
options: {
required: false,
type: Object,
default: {},
default: ()=>({}),
},
preview: {
required: false,
Expand Down
3 changes: 2 additions & 1 deletion resources/js/components/AttributeTemplate.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
<simple-search
:endpoint="searchLabel"
:key-fn="getConceptLabel"
@selected="e => labelSelected(e, 'label')"
:default-value="state.searchResetValue"
@selected="e => labelSelected(e, 'label')"
/>
</div>
</div>
Expand Down
Loading

0 comments on commit 0063830

Please sign in to comment.