Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[0.11] Add attribute usage indicator #519

Open
wants to merge 1 commit into
base: release-0.11
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
# Changelog
All notable changes to this project will be documented in this file.

## 0.10.1 - Dayjs Hotfix
## 0.11 -
### Added
- Indicator in _Data Model Editor_ that visualizes if an attribute is used in any entity-type

## 0.10.1
### Fixed
- Frontend errors due to wrong dayjs import

Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/EditorController.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public function getAttributes() {
'error' => __('You do not have the permission to view entity data')
], 403);
}
$attributes = Attribute::whereNull('parent_id')->orderBy('id')->get();
$attributes = Attribute::whereNull('parent_id')->withCount('entity_types')->orderBy('id')->get();
$selections = [];
foreach($attributes as $a) {
$selection = $a->getSelection();
Expand Down
11 changes: 7 additions & 4 deletions resources/js/components/AttributeList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,25 @@
<div
v-if="!state.hiddenAttributeList[element.id] || showHidden"
class="mb-3 px-2"
>
: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"
class="col-form-label col-md-3 d-flex flex-row justify-content-between gap-1 text-break"
:for="`attr-${element.id}`"
:class="attributeClasses(element)"
@click="e => handleLabelClick(e, element.datatype)"
>
<slot
name="preceding"
:attribute="element"
/>
<div
v-show="!!state.hoverStates[index]"
class="btn-fab-list"
Expand Down Expand Up @@ -623,7 +626,7 @@
updateDirtyState,
resetListValues,
undirtyList,
setRef,
setRef,
onEditHandler,
onRemoveHandler,
onDeleteHandler,
Expand Down
11 changes: 10 additions & 1 deletion resources/js/components/DataModel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,11 @@
:is-source="true"
:show-info="true"
@delete-element="onDeleteAttribute"
/>
>
<template #preceding="{attribute}">
<AttributeUsageIndicator :count="attribute.entity_types_count" />
</template>
</attribute-list>
</div>
</div>
</div>
Expand All @@ -97,6 +101,8 @@
import store from '@/bootstrap/store.js';
import router from '%router';

import AttributeUsageIndicator from '@/components/dme/AttributeUsageIndicator.vue';

import {
duplicateEntityType as duplicateEntityTypeApi,
getEntityTypeOccurrenceCount,
Expand All @@ -117,6 +123,9 @@
} from '@/helpers/modal.js';

export default {
components: {
AttributeUsageIndicator,
},
setup(props, context) {
const { t } = useI18n();
const currentRoute = useRoute();
Expand Down
53 changes: 53 additions & 0 deletions resources/js/components/dme/AttributeUsageIndicator.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<template>
<span
class="rounded-circle align-self-center"
:class="state.colorIndicator"
:style="`width: ${size}px; height: ${size}px;`"
:title="t('main.datamodel.attribute.indicator_info', {cnt: count}, count)"
/>
</template>

<script>
import {
computed,
reactive,
} from 'vue';

import { useI18n } from 'vue-i18n';

export default {
props: {
count: {
required: true,
type: Number,
},
size: {
required: false,
type: Number,
default: 8,
},
},
setup(props, context) {
const { t } = useI18n();

// FETCH

// FUNCTIONS

// DATA
const state = reactive({
positive: computed(_ => props.count > 0),
colorIndicator: computed(_ => state.positive ? 'bg-success' : 'bg-danger'),
});

// RETURN
return {
t,
// HELPERS
// LOCAL
// STATE
state,
};
},
};
</script>
1 change: 1 addition & 0 deletions resources/js/i18n/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -716,6 +716,7 @@
"title": "Verfügbare Attribute",
"add_button": "Attribut hinzufügen",
"show_hidden": "Ausgeblendete anzeigen",
"indicator_info": "Dieses Attribut wird aktuell in keinem Entitätstyp verwendet! | Dieses Attribut wird aktuell in einem Entitätstyp verwendet. | Dieses Attribut wird aktuell in {cnt} Entitätstypen verwendet.",
"modal": {
"new": {
"title": "Neues Attribut"
Expand Down
1 change: 1 addition & 0 deletions resources/js/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -716,6 +716,7 @@
"title": "Available Attributes",
"add_button": "Add Attribute",
"show_hidden": "Show hidden",
"indicator_info": "This attribute is not currently used in any entity-type! | This attribute is currently used in one entity-type. | This attribute is currently used in {cnt} entity-types.",
"modal": {
"new": {
"title": "New Attribute"
Expand Down
Loading