Skip to content

Commit

Permalink
Rule/Script edit: Fix not editable not properly handled & Always show…
Browse files Browse the repository at this point in the history
… tags (#2276)

Fixes an issue where the configuration of a script action of a
file-based rule (e.g. those created using JSRule or Rule Builder of
openhab-js) was shown as editable, even though the rule is not editable
because it is provisioned from file.

Always show the tag input, even if there are no rule tags. This is more
consistent and avoids confusion, as you can now clearly see that a rule
has no tags.

Signed-off-by: Florian Hotze <[email protected]>
  • Loading branch information
florian-h05 authored Jan 28, 2024
1 parent 1966ba3 commit a13d34a
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
pattern="[A-Za-z0-9_\-]+" error-message="Required. A-Z,a-z,0-9,_,- only"
@input="rule.uid = $event.target.value" :clear-button="createMode" />
<f7-list-input label="Name" type="text" placeholder="Required" :value="rule.name" required validate
:disabled="!isEditable" @input="rule.name = $event.target.value" :clear-button="isEditable" />
:disabled="!editable" @input="rule.name = $event.target.value" :clear-button="editable" />
<f7-list-input label="Description" type="text" :value="rule.description"
:disabled="!isEditable" @input="rule.description = $event.target.value" :clear-button="isEditable" />
<f7-list-item v-if="(isEditable || rule.tags.length > 0) && (!createMode || !hasRuleTemplate)" accordion-item title="Tags" :after="numberOfTags" :disabled="!isEditable">
:disabled="!editable" @input="rule.description = $event.target.value" :clear-button="editable" />
<f7-list-item v-if="!createMode || !hasRuleTemplate" accordion-item title="Tags" :after="numberOfTags">
<f7-accordion-content>
<tag-input :item="rule" :showSemanticTags="true" :inScriptEditor="inScriptEditor" :inSceneEditor="inSceneEditor" />
<tag-input :item="rule" :disabled="!editable" :showSemanticTags="true" :inScriptEditor="inScriptEditor" :inSceneEditor="inSceneEditor" />
</f7-accordion-content>
</f7-list-item>
</f7-list>
Expand All @@ -28,10 +28,10 @@
:disabled="true" :info="(createMode) ? 'Note: cannot be changed after the creation' : ''"
@input="rule.uid = $event.target.value" :clear-button="createMode" />
<f7-list-input label="Name" type="text" placeholder="Required" required validate
:disabled="true" @input="rule.name = $event.target.value" :clear-button="isEditable" />
:disabled="true" @input="rule.name = $event.target.value" :clear-button="editable" />
<f7-list-input label="Description" type="text" value="__ _____ ___ __ ___"
:disabled="true" @input="rule.description = $event.target.value" :clear-button="isEditable" />
<f7-list-item accordion-item title="Tags" :disabled="!isEditable">
:disabled="true" @input="rule.description = $event.target.value" :clear-button="editable" />
<f7-list-item accordion-item title="Tags" :disabled="!editable">
<f7-accordion-content>
<tag-input :item="rule" :showSemanticTags="true" />
</f7-accordion-content>
Expand All @@ -46,14 +46,17 @@
import TagInput from '@/components/tags/tag-input.vue'
export default {
props: ['rule', 'ready', 'createMode', 'isEditable', 'hasRuleTemplate', 'inScriptEditor', 'inSceneEditor'],
props: ['rule', 'ready', 'createMode', 'hasRuleTemplate', 'inScriptEditor', 'inSceneEditor'],
components: {
TagInput
},
computed: {
numberOfTags () {
if (!this.rule.tags) return 0
return this.rule.tags.filter((t) => !this.isScriptTag(t) && !this.isSceneTag(t)).length
},
editable () {
return this.rule && this.rule.editable
}
},
methods: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
</f7-col>
</f7-block>

<rule-general-settings :rule="rule" :ready="ready" :createMode="isNewRule" :isEditable="isEditable" :hasTemplate="hasTemplate" />
<rule-general-settings :rule="rule" :ready="ready" :createMode="isNewRule" :hasTemplate="hasTemplate" />

<f7-block v-if="ready" class="block-narrow">
<f7-block-footer v-if="!isEditable" class="no-margin padding-left">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
</f7-col>
</f7-block>

<rule-general-settings :rule="rule" :ready="ready" :createMode="createMode" :isEditable="isEditable" :isSceneEditor="true" />
<rule-general-settings :rule="rule" :ready="ready" :createMode="createMode" :isSceneEditor="true" />

<f7-block v-if="ready" class="block-narrow">
<f7-block-footer v-if="!isEditable" class="no-margin padding-left">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<f7-col v-if="!createMode && languages">
<f7-block-title>Scripting Language</f7-block-title>
<f7-list media-list>
<f7-list-item media-item radio radio-icon="start"
<f7-list-item media-item radio radio-icon="start" :disabled="true"
:value="mode" :checked="mode === language.contentType" @change="$emit('newLanguage', language.contentType)"
v-for="language in languages" :key="language.contentType"
:title="language.name" :after="language.version" :footer="language.contentType" />
Expand All @@ -23,6 +23,11 @@ export default {
emits: ['newLanguage'],
components: {
RuleGeneralSettings
},
computed: {
editable () {
return this.rule && this.rule.editable
}
}
}
</script>

0 comments on commit a13d34a

Please sign in to comment.