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

Feature: detail panel select #360

Open
wants to merge 10 commits into
base: main
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
7 changes: 7 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html)

## [Unreleased]

### Added

* Draw page:
* Add variables selection to each component detail drawer select fields.

## [1.3.0] - 2023/09/12

### Added
Expand Down
1,223 changes: 639 additions & 584 deletions package-lock.json

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"v-viewer": "=3.0.11",
"vue": "=3.3.4",
"vue-3-sanitize": "=0.1.4",
"vue-i18n": "=9.3.0",
"vue-i18n": "=9.4.0",
"vue-router": "=4.2.4"
},
"devDependencies": {
Expand All @@ -49,7 +49,7 @@
"@quasar/quasar-app-extension-testing-unit-jest": "=3.0.0-alpha.10",
"@vue/test-utils": "=2.4.1",
"@vue/vue3-jest": "=29.2.6",
"babel-jest": "=29.6.4",
"babel-jest": "=29.7.0",
"babel-loader": "=9.1.3",
"better-docs": "=2.7.2",
"cypress": "=12.17.4",
Expand All @@ -64,8 +64,8 @@
"eslint-plugin-vue": "=9.17.0",
"eslint-webpack-plugin": "=4.0.1",
"gherkin-lint": "=4.2.2",
"jest": "=29.6.4",
"jest-environment-jsdom": "=29.6.4",
"jest": "=29.7.0",
"jest-environment-jsdom": "=29.7.0",
"jest-serializer-vue": "=3.1.0",
"jest-sonar-reporter": "=2.0.0",
"jsdoc": "=4.0.2",
Expand Down
43 changes: 38 additions & 5 deletions src/components/inputs/ArrayInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,46 @@
:rules="[
(value) => isRequired($t, value, attribute.definition?.required),
]"
/>
>
<template #option="{ opt }">
<item-list
:item="opt"
@select-item="(value) => !localValue.includes(value) ? localValue.push(value) : null"
/>
</template>
</q-select>
</template>

<script setup>
import { ref, toRef, watch } from 'vue';
import {
onMounted,
ref,
toRefs,
watch,
} from 'vue';
import { isRequired } from 'src/composables/QuasarFieldRule';
import ItemList from 'components/inputs/ItemList';
import { initSelectOptions } from 'src/composables/InputManager';

const props = defineProps({
attribute: {
type: Object,
required: true,
},
plugin: {
type: Object,
required: true,
},
});

const emit = defineEmits(['update:model-value']);

const arrayInput = ref(null);
const options = toRef(props, 'attribute').value.definition.rules.values;
const localValue = ref(toRef(props, 'attribute').value.value);
const options = ref([]);
const { attribute, plugin } = toRefs(props);
const localValue = ref(attribute.value.value);
const defaultValues = ref(attribute.value.definition.rules.values || []);
const variables = ref(plugin.value.data.variables || []);

watch(() => arrayInput.value, () => {
if (arrayInput.value) {
Expand All @@ -38,10 +61,20 @@ watch(() => arrayInput.value, () => {
});

watch(() => props.attribute, () => {
localValue.value = props.attribute.value;
if (props.attribute.value) {
localValue.value = props.attribute.value;
}

if (arrayInput.value) {
arrayInput.value.validate();
}
});

watch(() => localValue.value, () => {
emit('update:model-value', localValue.value);
}, { deep: true });

onMounted(() => {
options.value = initSelectOptions(variables.value, defaultValues.value);
});
</script>
2 changes: 1 addition & 1 deletion src/components/inputs/AttributesList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<q-item
v-for="attribute in data.localAttributes.filter(({ type }) => type !== 'Object')"
:key="attribute.name"
class="q-px-none"
class="q-px-sm column"
>
<input-wrapper
class="col"
Expand Down
7 changes: 4 additions & 3 deletions src/components/inputs/InputWrapper.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
name="fa-solid fa-circle-info"
color="info"
size="xs"
class="q-ml-sm self-start"
style="cursor: help"
class="q-mr-md self-start"
style="cursor: help;"
>
<definition-menu
:definition="attribute.definition"
Expand All @@ -33,7 +33,8 @@
:is="inputList[getAttributeType(attribute)]"
:attribute="attribute"
:plugin="plugin"
class="col q-px-md"
class="col"
style="max-width: 280px"
:label="getAttributeLabel(attribute)"
hide-bottom-space
:full-name="fullName"
Expand Down
65 changes: 65 additions & 0 deletions src/components/inputs/ItemList.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<template>
<q-expansion-item
v-if="item.type === 'category'"
expand-separator
dense-toggle
:header-inset-level="0"
:label="$te(item.name) ? $t(item.name) : item.name"
header-class="text-weight-medium"
default-closed
>
<item-list
v-for="child in item.children"
:key="child.name"
:header-inset-level="0.2"
:item="child"
class="item-list"
@select-item="(value) => $emit('select-item', value)"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would put something more specific than 'select-name' as the event name, maybe "'item-clicked" or something like that

/>
</q-expansion-item>
<q-item
v-else
v-ripple
clickable
class="bg-grey-3"
@click="$emit('select-item', item.formattedName ? item.formattedName : item.value)"
>
<q-item-section
v-if="item.name"
class="item"
>
{{ item.name }}
</q-item-section>
<q-item-section
avatar
:class="!item.name ? item : null"
>
{{ item.value }}
</q-item-section>
</q-item>
</template>

<script setup>
import ItemList from 'components/inputs/ItemList';

defineProps({
item: {
type: Object,
required: true,
},
});

defineEmits(['select-item']);
</script>

<style scoped>
.item-list {
max-width: 280px;
max-height: 288px;
overflow-y: auto;
}
.item {
width: 50%;
word-break: break-all;
}
</style>
36 changes: 31 additions & 5 deletions src/components/inputs/LinkInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
v-model="localValue"
multiple
clearable
overflow-hidden
:options="options"
:rules="[
(value) => isRequired($t, value, attribute.definition?.required),
Expand All @@ -15,12 +16,25 @@
:name="`img:/plugins/${plugin.data.name}/icons/${iconName}.svg`"
/>
</template>
<template #option="{ opt }">
<item-list
:item="opt"
@select-item="(value) => localValue = [value]"
/>
</template>
</q-select>
</template>

<script setup>
import { ref, toRefs, watch } from 'vue';
import {
onMounted,
ref,
toRefs,
watch,
} from 'vue';
import { isRequired } from 'src/composables/QuasarFieldRule';
import ItemList from 'components/inputs/ItemList';
import { initSelectOptions } from 'src/composables/InputManager';

const props = defineProps({
attribute: {
Expand All @@ -33,18 +47,22 @@ const props = defineProps({
},
});

const emit = defineEmits(['update:model-value']);

const linkInput = ref(null);
const { attribute, plugin } = toRefs(props);
const localValue = ref(attribute.value.value);
const options = ref(plugin.value.data.getComponentsByType(
attribute.value.definition.linkRef,
).map(({ id }) => id));
const options = ref([]);
const iconName = ref(plugin.value.data.definitions.components.find(
({ type }) => type === attribute.value.definition.linkRef,
).icon);
const defaultValues = ref(plugin.value.data.getComponentsByType(
attribute.value.definition.linkRef,
).map(({ id }) => id));
const variables = ref(plugin.value.data.variables || []);

watch(() => props.plugin.data.components, () => {
options.value = props.plugin.data.getComponentsByType(
defaultValues.value = props.plugin.data.getComponentsByType(
props.attribute.definition.linkRef,
).map(({ id }) => id);
});
Expand All @@ -62,4 +80,12 @@ watch(() => props.attribute, () => {
linkInput.value.validate();
}
});

watch(() => localValue.value, () => {
emit('update:model-value', localValue.value);
});

onMounted(() => {
options.value = initSelectOptions(variables.value, defaultValues.value);
});
</script>
39 changes: 32 additions & 7 deletions src/components/inputs/ReferenceInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,25 @@
:name="`img:/plugins/${plugin.data.name}/icons/${iconName}.svg`"
/>
</template>
<template #option="{ opt }">
<item-list
:item="opt"
@select-item="(value) => localValue = [value]"
/>
</template>
</q-select>
</template>

<script setup>
import { ref, toRefs, watch } from 'vue';
import {
onMounted,
ref,
toRefs,
watch,
} from 'vue';
import { isRequired } from 'src/composables/QuasarFieldRule';
import ItemList from 'components/inputs/ItemList';
import { initSelectOptions } from 'src/composables/InputManager';

const props = defineProps({
attribute: {
Expand All @@ -32,19 +45,23 @@ const props = defineProps({
},
});

const { attribute, plugin } = toRefs(props);
const emit = defineEmits(['update:model-value']);

const referenceInput = ref(null);
const { attribute, plugin } = toRefs(props);
const localValue = ref(attribute.value.value);
const options = ref(plugin.value.data.getComponentsByType(
attribute.value.definition.containerRef,
plugin.value.data.components,
).map(({ id }) => id));
const options = ref([]);
const iconName = ref(plugin.value.data.definitions.components.find(
({ type }) => type === attribute.value.definition.containerRef,
).icon);
const defaultValues = ref(plugin.value.data.getComponentsByType(
attribute.value.definition.containerRef,
plugin.value.data.components,
).map(({ id }) => id));
const variables = ref(plugin.value.data.variables || []);

watch(() => props.plugin.data.components, () => {
options.value = props.plugin.data.getComponentsByType(
defaultValues.value = props.plugin.data.getComponentsByType(
props.attribute.definition.containerRef,
).map(({ id }) => id);
});
Expand All @@ -62,4 +79,12 @@ watch(() => props.attribute, () => {
referenceInput.value.validate();
}
});

watch(() => localValue.value, () => {
emit('update:model-value', localValue.value);
});

onMounted(() => {
options.value = initSelectOptions(variables.value, defaultValues.value);
});
</script>
Loading