Skip to content

Commit d70415a

Browse files
committed
Apply code review fixes
Signed-off-by: Kostiantyn Miakshyn <[email protected]>
1 parent 3e57297 commit d70415a

File tree

4 files changed

+15
-13
lines changed

4 files changed

+15
-13
lines changed

src/shared/components/ncTable/mixins/columnHandler.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,9 @@ export const ColumnTypes = {
1818
Datetime: 'datetime',
1919
Usergroup: 'usergroup',
2020
}
21+
22+
export function getColumnWidthStyle(column) {
23+
const width = column.customSettings?.width ? `min(${column.customSettings.width}px, 90vw)` : null
24+
25+
return width ? { width, maxWidth: width, minWidth: width } : null
26+
}

src/shared/components/ncTable/partials/TableHeader.vue

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,7 @@
1010
<div v-if="hasRightHiddenNeighbor(-1)" class="hidden-indicator-first" @click="unhide(-1)" />
1111
</div>
1212
</th>
13-
<th v-for="col in visibleColumns" :key="col.id"
14-
:style="{
15-
width: col.customSettings?.width ? `${col.customSettings.width}px` : 'auto',
16-
maxWidth: col.customSettings?.width ? `${col.customSettings.width}px` : 'auto',
17-
minWidth: col.customSettings?.width ? `${col.customSettings.width}px` : 'auto'}">
13+
<th v-for="col in visibleColumns" :key="col.id" :style="getColumnWidthStyle(col)">
1814
<div class="cell-wrapper">
1915
<div class="cell-options-wrapper">
2016
<div class="cell">
@@ -52,6 +48,7 @@ import { NcCheckboxRadioSwitch } from '@nextcloud/vue'
5248
import TableHeaderColumnOptions from './TableHeaderColumnOptions.vue'
5349
import FilterLabel from './FilterLabel.vue'
5450
import { getFilterWithId } from '../mixins/filter.js'
51+
import { getColumnWidthStyle } from '../mixins/columnHandler.js'
5552
5653
export default {
5754
@@ -114,6 +111,7 @@ export default {
114111
115112
methods: {
116113
getFilterWithId,
114+
getColumnWidthStyle,
117115
updateOpenState(columnId) {
118116
this.openedColumnHeaderMenus[columnId] = !this.openedColumnHeaderMenus[columnId]
119117
this.openedColumnHeaderMenus = Object.assign({}, this.openedColumnHeaderMenus)

src/shared/components/ncTable/partials/TableRow.vue

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,7 @@
88
<NcCheckboxRadioSwitch :checked="selected" @update:checked="v => $emit('update-row-selection', { rowId: row.id, value: v })" />
99
</td>
1010
<td v-for="col in visibleColumns" :key="col.id"
11-
:style="{
12-
width: col.customSettings?.width ? `${col.customSettings.width}px` : 'auto',
13-
maxWidth: col.customSettings?.width ? `${col.customSettings.width}px` : 'auto',
14-
minWidth: col.customSettings?.width ? `${col.customSettings.width}px` : 'auto'}"
11+
:style="getColumnWidthStyle(col)"
1512
:class="{
1613
'search-result': getCell(col.id)?.searchStringFound,
1714
'filter-result': getCell(col.id)?.filterFound,
@@ -51,7 +48,7 @@ import TableCellSelection from './TableCellSelection.vue'
5148
import TableCellMultiSelection from './TableCellMultiSelection.vue'
5249
import TableCellTextRich from './TableCellEditor.vue'
5350
import TableCellUsergroup from './TableCellUsergroup.vue'
54-
import { ColumnTypes } from './../mixins/columnHandler.js'
51+
import { ColumnTypes, getColumnWidthStyle } from './../mixins/columnHandler.js'
5552
import { translate as t } from '@nextcloud/l10n'
5653
import {
5754
TYPE_META_ID, TYPE_META_CREATED_BY, TYPE_META_CREATED_AT, TYPE_META_UPDATED_BY, TYPE_META_UPDATED_AT,
@@ -125,6 +122,7 @@ export default {
125122
},
126123
methods: {
127124
t,
125+
getColumnWidthStyle,
128126
handleCellClick(column) {
129127
// If the column type doesn't support inline editing, trigger the edit modal
130128
if (this.nonInlineEditableColumnTypes.includes(column.type) && this.config.canEditRows) {

src/shared/components/ncTable/partials/columnTypePartials/forms/MainForm.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@
3737
v-model.number="localColumnWidth"
3838
type="number"
3939
pattern="\d+"
40-
min="20"
41-
max="1000"
40+
:min="COLUMN_WIDTH_MIN"
41+
:max="COLUMN_WIDTH_MAX"
4242
:placeholder="t('tables', 'Enter a column width between {min} and {max}', { min: COLUMN_WIDTH_MIN, max: COLUMN_WIDTH_MAX })">
4343
</div>
4444

@@ -148,7 +148,7 @@ export default {
148148
},
149149
},
150150
localColumnWidth: {
151-
get() { return this.customSettings.width ?? null },
151+
get() { return this.customSettings?.width ?? null },
152152
set(width) {
153153
this.$emit('update:customSettings', { ...this.customSettings, ...{ width } })
154154
},

0 commit comments

Comments
 (0)