Skip to content

Commit 433c9d5

Browse files
committed
Enhancement: add a read-only option to view columns (code review fixes)
Signed-off-by: Kostiantyn Miakshyn <molodchick@gmail.com>
1 parent bffc3fc commit 433c9d5

17 files changed

Lines changed: 55 additions & 29 deletions

src/modules/main/partials/ColumnFormComponent.vue

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,3 +90,9 @@ export default {
9090
},
9191
}
9292
</script>
93+
94+
<style lang="scss" scoped>
95+
:deep(input[readonly]) {
96+
opacity: 0.6;
97+
}
98+
</style>

src/modules/modals/CreateRow.vue

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
data-cy="createRowModal"
1010
@closing="actionCancel">
1111
<div class="modal__content" @keydown="onKeydown">
12-
<div v-for="column in editableColumns" :key="column.id" :data-cy="column.title">
12+
<div v-for="column in nonMetaColumns" :key="column.id" :data-cy="column.title">
1313
<ColumnFormComponent
1414
:column="column"
1515
:value.sync="row[column.id]" />
@@ -86,16 +86,14 @@ export default {
8686
}
8787
},
8888
computed: {
89-
editableColumns() {
90-
return this.columns
91-
.filter(col => col.id >= 0)
92-
.filter(col => !col.readonly)
89+
nonMetaColumns() {
90+
return this.columns.filter(col => col.id >= 0)
9391
},
9492
hasEmptyMandatoryRows() {
9593
return this.checkMandatoryFields(this.row)
9694
},
9795
hasInvalidUrlProtocol() {
98-
return this.editableColumns.some(col => col.type === 'text-link' && !this.isValidUrlProtocol(this.row[col.id]))
96+
return this.nonMetaColumns.some(col => col.type === 'text-link' && !this.isValidUrlProtocol(this.row[col.id]))
9997
},
10098
},
10199
watch: {

src/modules/modals/EditRow.vue

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
size="large"
1010
@closing="actionCancel">
1111
<div class="modal__content" @keydown="onKeydown">
12-
<div v-for="column in editableColumns" :key="column.id">
12+
<div v-for="column in nonMetaColumns" :key="column.id">
1313
<ColumnFormComponent
1414
:column="column"
1515
:value.sync="localRow[column.id]" />
@@ -106,16 +106,14 @@ export default {
106106
showDeleteButton() {
107107
return this.canDeleteData(this.element) && !this.localLoading
108108
},
109-
editableColumns() {
110-
return this.columns
111-
.filter(col => col.id >= 0)
112-
.filter(col => !col.readonly)
109+
nonMetaColumns() {
110+
return this.columns.filter(col => col.id >= 0)
113111
},
114112
hasEmptyMandatoryRows() {
115113
return this.checkMandatoryFields(this.localRow)
116114
},
117115
hasInvalidUrlProtocol() {
118-
return this.editableColumns.some(col => col.type === 'text-link' && !this.isValidUrlProtocol(this.localRow[col.id]))
116+
return this.nonMetaColumns.some(col => col.type === 'text-link' && !this.isValidUrlProtocol(this.localRow[col.id]))
119117
},
120118
},
121119
watch: {
@@ -183,7 +181,6 @@ export default {
183181
},
184182
reset() {
185183
this.localRow = {}
186-
this.dataLoaded = false
187184
this.prepareDeleteRow = false
188185
},
189186
actionDeleteRow() {

src/shared/components/ncTable/partials/rowTypePartials/DatetimeDateForm.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
-->
55
<template>
66
<RowFormWrapper :title="column.title" :mandatory="column.mandatory" :description="column.description" :width="2">
7-
<NcDateTimePickerNative id="datetime-date-picker" v-model="localValue"
7+
<NcDateTimePickerNative id="datetime-date-picker" v-model="localValue" :readonly="column.readonly"
88
type="date" />
99
<div v-if="canBeCleared" class="icon-close make-empty" @click="emptyValue" />
1010
</RowFormWrapper>
@@ -36,7 +36,7 @@ export default {
3636
},
3737
computed: {
3838
canBeCleared() {
39-
return !this.column.mandatory
39+
return !this.column.readonly && !this.column.mandatory
4040
},
4141
localValue: {
4242
get() {

src/shared/components/ncTable/partials/rowTypePartials/DatetimeForm.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
-->
55
<template>
66
<RowFormWrapper :title="column.title" :mandatory="column.mandatory" :description="column.description" :width="2">
7-
<NcDateTimePickerNative id="datetime-picker" v-model="localValue"
7+
<NcDateTimePickerNative id="datetime-picker" v-model="localValue" :readonly="column.readonly"
88
type="datetime-local" />
99
<div v-if="canBeCleared" class="icon-close make-empty" @click="emptyValue" />
1010
</RowFormWrapper>
@@ -32,7 +32,7 @@ export default {
3232
},
3333
computed: {
3434
canBeCleared() {
35-
return !this.column.mandatory
35+
return !this.column.readonly && !this.column.mandatory
3636
},
3737
localValue: {
3838
get() {

src/shared/components/ncTable/partials/rowTypePartials/DatetimeTimeForm.vue

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@
44
-->
55
<template>
66
<RowFormWrapper :title="column.title" :mandatory="column.mandatory" :description="column.description" :width="2">
7-
<NcDateTimePickerNative id="datetime-time-picker" v-model="localValue" :label="t('tables', 'Please select a new time')"
7+
<NcDateTimePickerNative
8+
id="datetime-time-picker"
9+
v-model="localValue"
10+
:label="t('tables', 'Please select a new time')"
11+
:readonly="column.readonly"
812
type="time" />
913
<div v-if="canBeCleared" class="icon-close make-empty" @click="emptyValue" />
1014
</RowFormWrapper>
@@ -36,7 +40,7 @@ export default {
3640
},
3741
computed: {
3842
canBeCleared() {
39-
return !this.column.mandatory
43+
return !this.column.readonly && !this.column.mandatory
4044
},
4145
localValue: {
4246
get() {

src/shared/components/ncTable/partials/rowTypePartials/NumberForm.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
type="number"
1212
:min="column.numberMin"
1313
:max="column.numberMax"
14+
:readonly="column.readonly"
1415
:step="getStep">
1516
<div v-if="column.numberSuffix" class="suffix">
1617
{{ column.numberSuffix }}

src/shared/components/ncTable/partials/rowTypePartials/NumberProgressForm.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
type="number"
99
min="0"
1010
max="100"
11+
:readonly="column.readonly"
1112
@input="enforceBounds">
1213
</RowFormWrapper>
1314
</template>

src/shared/components/ncTable/partials/rowTypePartials/NumberStarsForm.vue

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@
55
<template>
66
<RowFormWrapper :title="column.title" :mandatory="column.mandatory" :description="column.description">
77
<div class="align-center">
8-
<NcButton type="tertiary" :aria-label="t('tables', 'Reduce stars')" @click="less">
8+
<NcButton type="tertiary" :aria-label="t('tables', 'Reduce stars')" :disabled="column.readonly || localValue <= 0" @click="less">
99
<template #icon>
1010
<Minus :size="20" />
1111
</template>
1212
</NcButton>
13-
<div class="stars">
13+
<div class="stars" :class="{ 'readonly': column.readonly }">
1414
{{ getStars }}
1515
</div>
16-
<NcButton type="tertiary" :aria-label="t('tables', 'Increase stars')" @click="more">
16+
<NcButton type="tertiary" :aria-label="t('tables', 'Increase stars')" :disabled="column.readonly || localValue >= 5" @click="more">
1717
<template #icon>
1818
<Plus :size="20" />
1919
</template>
@@ -91,10 +91,12 @@ export default {
9191
align-items: center;
9292
display: inline-flex;
9393
}
94-
9594
.stars {
9695
font-size: 1.4em;
9796
padding: 7px;
9897
}
98+
.stars.readonly {
99+
opacity: 0.6;
100+
}
99101
100102
</style>

src/shared/components/ncTable/partials/rowTypePartials/SelectionCheckForm.vue

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@
44
-->
55
<template>
66
<RowFormWrapper :title="column.title" :mandatory="column.mandatory" :description="column.description">
7-
<NcCheckboxRadioSwitch type="switch" :checked.sync="localValue" data-cy="selectionCheckFormSwitch" />
7+
<NcCheckboxRadioSwitch
8+
type="switch"
9+
:checked.sync="localValue"
10+
:disabled="column.readonly"
11+
data-cy="selectionCheckFormSwitch" />
812
</RowFormWrapper>
913
</template>
1014

0 commit comments

Comments
 (0)