|
15 | 15 | :title.sync="column.title" |
16 | 16 | :custom-settings.sync="column.customSettings" |
17 | 17 | :selected-views.sync="column.selectedViews" |
18 | | - :title-missing-error="titleMissingError" /> |
| 18 | + :title-missing-error="titleMissingError" |
| 19 | + :width-invalid-error="widthInvalidError" /> |
19 | 20 | </div> |
20 | 21 | <div class="fix-col-2" style="display: block"> |
21 | 22 | <div class="row no-padding-on-mobile space-L"> |
@@ -115,6 +116,7 @@ import UsergroupForm from '../../shared/components/ncTable/partials/columnTypePa |
115 | 116 | import { useTablesStore } from '../../store/store.js' |
116 | 117 | import { useDataStore } from '../../store/data.js' |
117 | 118 | import { mapActions } from 'pinia' |
| 119 | +import { COLUMN_WIDTH_MAX, COLUMN_WIDTH_MIN } from '../../shared/constants.js' |
118 | 120 |
|
119 | 121 | export default { |
120 | 122 | name: 'CreateColumn', |
@@ -193,6 +195,7 @@ export default { |
193 | 195 | textAppAvailable: !!window.OCA?.Text?.createEditor, |
194 | 196 | addNewAfterSave: false, |
195 | 197 | typeMissingError: false, |
| 198 | + widthInvalidError: false, |
196 | 199 | titleMissingError: false, |
197 | 200 | typeOptions: [ |
198 | 201 | { id: 'text', label: t('tables', 'Text') }, |
@@ -290,10 +293,10 @@ export default { |
290 | 293 | showInfo(t('tables', 'Please insert a title for the new column.')) |
291 | 294 | this.titleMissingError = true |
292 | 295 | } else if (this.column.customSettings?.width |
293 | | - && (this.column.customSettings?.width < 20 || this.column.customSettings?.width > 1000)) { |
| 296 | + && (this.column.customSettings?.width < COLUMN_WIDTH_MIN || this.column.customSettings?.width > COLUMN_WIDTH_MAX)) { |
294 | 297 | this.titleMissingError = false |
295 | | - showError(t('tables', 'Cannot save column. Column width must be between {min} and {max}.', { min: 20, max: 1000 })) |
296 | | - this.typeMissingError = true |
| 298 | + showError(t('tables', 'Cannot save column. Column width must be between {min} and {max}.', { min: COLUMN_WIDTH_MIN, max: COLUMN_WIDTH_MAX })) |
| 299 | + this.widthInvalidError = true |
297 | 300 | } else if (this.column.type === null) { |
298 | 301 | this.titleMissingError = false |
299 | 302 | showInfo(t('tables', 'You need to select a type for the new column.')) |
@@ -328,9 +331,8 @@ export default { |
328 | 331 | mandatory: this.column.mandatory, |
329 | 332 | viewId: this.isView ? this.element.id : null, |
330 | 333 | tableId: !this.isView ? this.element.id : null, |
331 | | - customSettings: this.column.customSettings, |
| 334 | + customSettings: { width: this.column.customSettings.width }, |
332 | 335 | } |
333 | | - data.customSettings = { width: data.customSettings.width } |
334 | 336 |
|
335 | 337 | if (this.combinedType === ColumnTypes.TextLine) { |
336 | 338 | data.textUnique = this.column.textUnique |
@@ -435,6 +437,7 @@ export default { |
435 | 437 | this.column.selectedViews = [] |
436 | 438 | } |
437 | 439 | this.titleMissingError = false |
| 440 | + this.widthInvalidError = false |
438 | 441 | this.typeMissingError = false |
439 | 442 | }, |
440 | 443 | }, |
|
0 commit comments