Skip to content

Commit

Permalink
Add CompareSaveDialog component to group EditPanel
Browse files Browse the repository at this point in the history
  • Loading branch information
JanAckermann committed Apr 6, 2022
1 parent 85dc53e commit 99aa3de
Showing 1 changed file with 34 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,25 @@
:fix-message-line="true"
@input="validateDisplayName"
/>
<oc-button @click="$emit('confirm', editGroup)">ok</oc-button>
</div>
<compare-save-dialog
class="edit-compare-save-dialog"
:original-object="group"
:compare-object="editGroup"
:confirm-button-disabled="invalidFormData"
@revert="revertChanges"
@confirm="$emit('confirm', editGroup)"
></compare-save-dialog>
</div>
</template>
<script>
import CompareSaveDialog from '../../CompareSaveDialog.vue'
export default {
name: 'EditPanel',
components: {
CompareSaveDialog
},
props: {
group: {
type: Object,
Expand All @@ -37,6 +49,13 @@ export default {
}
}
},
computed: {
invalidFormData() {
return Object.keys(this.formData)
.map((k) => !!this.formData[k].valid)
.includes(false)
}
},
watch: {
group: {
handler: function () {
Expand All @@ -58,11 +77,25 @@ export default {
this.formData.displayName.errorMessage = ''
this.formData.displayName.valid = true
return true
},
revertChanges() {
this.editGroup = { ...this.group }
Object.keys(this.formData).forEach((formDataKey) => {
this.formData[formDataKey].invalid = false
this.formData[formDataKey].errorMessage = ''
})
}
}
}
</script>
<style lang="scss">
.edit-compare-save-dialog {
position: absolute;
bottom: 0;
left: 0;
}
.group-info {
align-items: center;
flex-direction: column;
Expand Down

0 comments on commit 99aa3de

Please sign in to comment.