mirror of
https://gitlab.com/bramw/baserow.git
synced 2025-04-14 00:59:06 +00:00
Remove primary from table
This commit is contained in:
parent
0007cfbc64
commit
aae90f477f
61 changed files with 426 additions and 902 deletions
changelog.md
premium/web-frontend
modules/baserow_premium
components/views
store/view
viewTypes.jstest/unit/premium/store/view
web-frontend
modules/database
components
field
row
table
view
ViewDecoratorContext.vueViewDecoratorMenu.vueViewFieldConditionsForm.vueViewFilter.vueViewFilterForm.vueViewFilterTypeFileTypeDropdown.vueViewSearch.vueViewSearchContext.vueViewSort.vueViewSortContext.vue
form
gallery
grid
webhook
mixins
pages
realtime.jsstore
utils
viewTypes.jstest/unit/database
components/view
store/view
utils
viewFilters.spec.js
|
@ -29,6 +29,7 @@ For example:
|
||||||
|
|
||||||
### Breaking Changes
|
### Breaking Changes
|
||||||
* API endpoints `undo` and `redo` now returns a list of actions undone/redone instead of a single action.
|
* API endpoints `undo` and `redo` now returns a list of actions undone/redone instead of a single action.
|
||||||
|
* Removed `primary` from all `components`and `stores` where it isn't absolutely required. [#1057](https://gitlab.com/bramw/baserow/-/issues/1057)
|
||||||
|
|
||||||
* **breaking change** Webhooks `row.created`, `row.updated` and `row.deleted` are
|
* **breaking change** Webhooks `row.created`, `row.updated` and `row.deleted` are
|
||||||
replaced with `rows.created`, `rows.updated` and `rows.deleted`, containing multiple
|
replaced with `rows.created`, `rows.updated` and `rows.deleted`, containing multiple
|
||||||
|
|
|
@ -46,7 +46,6 @@
|
||||||
:filters="color.filters"
|
:filters="color.filters"
|
||||||
:disable-filter="false"
|
:disable-filter="false"
|
||||||
:filter-type="color.operator"
|
:filter-type="color.operator"
|
||||||
:primary="primary"
|
|
||||||
:fields="fields"
|
:fields="fields"
|
||||||
:view="view"
|
:view="view"
|
||||||
:read-only="readOnly"
|
:read-only="readOnly"
|
||||||
|
@ -95,10 +94,6 @@ export default {
|
||||||
type: Object,
|
type: Object,
|
||||||
required: true,
|
required: true,
|
||||||
},
|
},
|
||||||
primary: {
|
|
||||||
type: Object,
|
|
||||||
required: true,
|
|
||||||
},
|
|
||||||
fields: {
|
fields: {
|
||||||
type: Array,
|
type: Array,
|
||||||
required: true,
|
required: true,
|
||||||
|
@ -108,11 +103,6 @@ export default {
|
||||||
required: true,
|
required: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
computed: {
|
|
||||||
allFields() {
|
|
||||||
return [this.primary, ...this.fields]
|
|
||||||
},
|
|
||||||
},
|
|
||||||
methods: {
|
methods: {
|
||||||
orderColor(colorIds) {
|
orderColor(colorIds) {
|
||||||
const newColors = colorIds.map((colorId) =>
|
const newColors = colorIds.map((colorId) =>
|
||||||
|
@ -138,7 +128,7 @@ export default {
|
||||||
ConditionalColorValueProviderType.getDefaultColorConf(
|
ConditionalColorValueProviderType.getDefaultColorConf(
|
||||||
this.$registry,
|
this.$registry,
|
||||||
{
|
{
|
||||||
fields: this.allFields,
|
fields: this.fields,
|
||||||
},
|
},
|
||||||
true
|
true
|
||||||
),
|
),
|
||||||
|
@ -176,7 +166,7 @@ export default {
|
||||||
ConditionalColorValueProviderType.getDefaultFilterConf(
|
ConditionalColorValueProviderType.getDefaultFilterConf(
|
||||||
this.$registry,
|
this.$registry,
|
||||||
{
|
{
|
||||||
fields: this.allFields,
|
fields: this.fields,
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|
|
@ -33,10 +33,6 @@ export default {
|
||||||
type: Object,
|
type: Object,
|
||||||
required: true,
|
required: true,
|
||||||
},
|
},
|
||||||
primary: {
|
|
||||||
type: Object,
|
|
||||||
required: true,
|
|
||||||
},
|
|
||||||
fields: {
|
fields: {
|
||||||
type: Array,
|
type: Array,
|
||||||
required: true,
|
required: true,
|
||||||
|
@ -48,7 +44,7 @@ export default {
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
selectFields() {
|
selectFields() {
|
||||||
return [this.primary, ...this.fields].filter(
|
return this.fields.filter(
|
||||||
({ type }) => type === SingleSelectFieldType.getType()
|
({ type }) => type === SingleSelectFieldType.getType()
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
:table="table"
|
:table="table"
|
||||||
:view="view"
|
:view="view"
|
||||||
:fields="fields"
|
:fields="fields"
|
||||||
:primary="primary"
|
|
||||||
:read-only="readOnly"
|
:read-only="readOnly"
|
||||||
:store-prefix="storePrefix"
|
:store-prefix="storePrefix"
|
||||||
:include-field-options-on-refresh="true"
|
:include-field-options-on-refresh="true"
|
||||||
|
@ -29,7 +28,6 @@
|
||||||
:view="view"
|
:view="view"
|
||||||
:card-fields="cardFields"
|
:card-fields="cardFields"
|
||||||
:fields="fields"
|
:fields="fields"
|
||||||
:primary="primary"
|
|
||||||
:read-only="readOnly"
|
:read-only="readOnly"
|
||||||
:store-prefix="storePrefix"
|
:store-prefix="storePrefix"
|
||||||
@create-row="openCreateRowModal"
|
@create-row="openCreateRowModal"
|
||||||
|
@ -45,7 +43,6 @@
|
||||||
:view="view"
|
:view="view"
|
||||||
:card-fields="cardFields"
|
:card-fields="cardFields"
|
||||||
:fields="fields"
|
:fields="fields"
|
||||||
:primary="primary"
|
|
||||||
:read-only="readOnly"
|
:read-only="readOnly"
|
||||||
:store-prefix="storePrefix"
|
:store-prefix="storePrefix"
|
||||||
@create-row="openCreateRowModal"
|
@create-row="openCreateRowModal"
|
||||||
|
@ -63,14 +60,12 @@
|
||||||
<KanbanViewCreateStackContext
|
<KanbanViewCreateStackContext
|
||||||
ref="addOptionContext"
|
ref="addOptionContext"
|
||||||
:fields="fields"
|
:fields="fields"
|
||||||
:primary="primary"
|
|
||||||
:store-prefix="storePrefix"
|
:store-prefix="storePrefix"
|
||||||
></KanbanViewCreateStackContext>
|
></KanbanViewCreateStackContext>
|
||||||
</div>
|
</div>
|
||||||
<RowCreateModal
|
<RowCreateModal
|
||||||
ref="rowCreateModal"
|
ref="rowCreateModal"
|
||||||
:table="table"
|
:table="table"
|
||||||
:primary="primary"
|
|
||||||
:primary-is-sortable="true"
|
:primary-is-sortable="true"
|
||||||
:visible-fields="cardFields"
|
:visible-fields="cardFields"
|
||||||
:hidden-fields="hiddenFields"
|
:hidden-fields="hiddenFields"
|
||||||
|
@ -88,7 +83,6 @@
|
||||||
ref="rowEditModal"
|
ref="rowEditModal"
|
||||||
:database="database"
|
:database="database"
|
||||||
:table="table"
|
:table="table"
|
||||||
:primary="primary"
|
|
||||||
:primary-is-sortable="true"
|
:primary-is-sortable="true"
|
||||||
:visible-fields="cardFields"
|
:visible-fields="cardFields"
|
||||||
:hidden-fields="hiddenFields"
|
:hidden-fields="hiddenFields"
|
||||||
|
@ -155,10 +149,6 @@ export default {
|
||||||
type: Array,
|
type: Array,
|
||||||
required: true,
|
required: true,
|
||||||
},
|
},
|
||||||
primary: {
|
|
||||||
type: Object,
|
|
||||||
required: true,
|
|
||||||
},
|
|
||||||
readOnly: {
|
readOnly: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
required: true,
|
required: true,
|
||||||
|
@ -176,15 +166,13 @@ export default {
|
||||||
*/
|
*/
|
||||||
cardFields() {
|
cardFields() {
|
||||||
const fieldOptions = this.fieldOptions
|
const fieldOptions = this.fieldOptions
|
||||||
return [this.primary]
|
return this.fields
|
||||||
.concat(this.fields)
|
|
||||||
.filter(filterVisibleFieldsFunction(fieldOptions))
|
.filter(filterVisibleFieldsFunction(fieldOptions))
|
||||||
.sort(sortFieldsByOrderAndIdFunction(fieldOptions))
|
.sort(sortFieldsByOrderAndIdFunction(fieldOptions))
|
||||||
},
|
},
|
||||||
hiddenFields() {
|
hiddenFields() {
|
||||||
const fieldOptions = this.fieldOptions
|
const fieldOptions = this.fieldOptions
|
||||||
return [this.primary]
|
return this.fields
|
||||||
.concat(this.fields)
|
|
||||||
.filter(filterHiddenFieldsFunction(fieldOptions))
|
.filter(filterHiddenFieldsFunction(fieldOptions))
|
||||||
.sort(sortFieldsByOrderAndIdFunction(fieldOptions))
|
.sort(sortFieldsByOrderAndIdFunction(fieldOptions))
|
||||||
},
|
},
|
||||||
|
@ -193,7 +181,7 @@ export default {
|
||||||
* cards in stacks.
|
* cards in stacks.
|
||||||
*/
|
*/
|
||||||
singleSelectField() {
|
singleSelectField() {
|
||||||
const allFields = [this.primary].concat(this.fields)
|
const allFields = this.fields
|
||||||
for (let i = 0; i < allFields.length; i++) {
|
for (let i = 0; i < allFields.length; i++) {
|
||||||
if (allFields[i].id === this.singleSelectFieldId) {
|
if (allFields[i].id === this.singleSelectFieldId) {
|
||||||
return allFields[i]
|
return allFields[i]
|
||||||
|
@ -239,7 +227,6 @@ export default {
|
||||||
view: this.view,
|
view: this.view,
|
||||||
table: this.table,
|
table: this.table,
|
||||||
fields: this.fields,
|
fields: this.fields,
|
||||||
primary: this.primary,
|
|
||||||
values: row,
|
values: row,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
@ -256,7 +243,6 @@ export default {
|
||||||
table: this.table,
|
table: this.table,
|
||||||
view: this.view,
|
view: this.view,
|
||||||
fields: this.fields,
|
fields: this.fields,
|
||||||
primary: this.primary,
|
|
||||||
row,
|
row,
|
||||||
field,
|
field,
|
||||||
value,
|
value,
|
||||||
|
|
|
@ -28,10 +28,6 @@ export default {
|
||||||
type: Array,
|
type: Array,
|
||||||
required: true,
|
required: true,
|
||||||
},
|
},
|
||||||
primary: {
|
|
||||||
type: Object,
|
|
||||||
required: true,
|
|
||||||
},
|
|
||||||
storePrefix: {
|
storePrefix: {
|
||||||
type: String,
|
type: String,
|
||||||
required: true,
|
required: true,
|
||||||
|
@ -51,7 +47,6 @@ export default {
|
||||||
this.storePrefix + 'view/kanban/createStack',
|
this.storePrefix + 'view/kanban/createStack',
|
||||||
{
|
{
|
||||||
fields: this.fields,
|
fields: this.fields,
|
||||||
primary: this.primary,
|
|
||||||
color: values.color,
|
color: values.color,
|
||||||
value: values.value,
|
value: values.value,
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,6 @@
|
||||||
:table="table"
|
:table="table"
|
||||||
:view="view"
|
:view="view"
|
||||||
:fields="fields"
|
:fields="fields"
|
||||||
:primary="primary"
|
|
||||||
:read-only="readOnly"
|
:read-only="readOnly"
|
||||||
:store-prefix="storePrefix"
|
:store-prefix="storePrefix"
|
||||||
@refresh="$emit('refresh', $event)"
|
@refresh="$emit('refresh', $event)"
|
||||||
|
@ -57,7 +56,7 @@
|
||||||
</a>
|
</a>
|
||||||
<ViewFieldsContext
|
<ViewFieldsContext
|
||||||
ref="customizeContext"
|
ref="customizeContext"
|
||||||
:fields="allFields"
|
:fields="fields"
|
||||||
:read-only="readOnly"
|
:read-only="readOnly"
|
||||||
:field-options="fieldOptions"
|
:field-options="fieldOptions"
|
||||||
:cover-image-field="view.card_cover_image_field"
|
:cover-image-field="view.card_cover_image_field"
|
||||||
|
@ -100,10 +99,6 @@ export default {
|
||||||
type: Array,
|
type: Array,
|
||||||
required: true,
|
required: true,
|
||||||
},
|
},
|
||||||
primary: {
|
|
||||||
type: Object,
|
|
||||||
required: true,
|
|
||||||
},
|
|
||||||
readOnly: {
|
readOnly: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
required: true,
|
required: true,
|
||||||
|
@ -111,17 +106,13 @@ export default {
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
stackedByFieldName() {
|
stackedByFieldName() {
|
||||||
const allFields = [this.primary].concat(this.fields)
|
for (let i = 0; i < this.fields.length; i++) {
|
||||||
for (let i = 0; i < allFields.length; i++) {
|
if (this.fields[i].id === this.view.single_select_field) {
|
||||||
if (allFields[i].id === this.view.single_select_field) {
|
return this.fields[i].name
|
||||||
return allFields[i].name
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ''
|
return ''
|
||||||
},
|
},
|
||||||
allFields() {
|
|
||||||
return [this.primary].concat(this.fields)
|
|
||||||
},
|
|
||||||
...mapState({
|
...mapState({
|
||||||
tableLoading: (state) => state.table.loading,
|
tableLoading: (state) => state.table.loading,
|
||||||
}),
|
}),
|
||||||
|
|
|
@ -52,7 +52,6 @@
|
||||||
ref="editContext"
|
ref="editContext"
|
||||||
:option="option"
|
:option="option"
|
||||||
:fields="fields"
|
:fields="fields"
|
||||||
:primary="primary"
|
|
||||||
:store-prefix="storePrefix"
|
:store-prefix="storePrefix"
|
||||||
@create-row="$emit('create-row', { option })"
|
@create-row="$emit('create-row', { option })"
|
||||||
@refresh="$emit('refresh', $event)"
|
@refresh="$emit('refresh', $event)"
|
||||||
|
@ -167,10 +166,6 @@ export default {
|
||||||
type: Array,
|
type: Array,
|
||||||
required: true,
|
required: true,
|
||||||
},
|
},
|
||||||
primary: {
|
|
||||||
type: Object,
|
|
||||||
required: true,
|
|
||||||
},
|
|
||||||
readOnly: {
|
readOnly: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
required: true,
|
required: true,
|
||||||
|
@ -229,11 +224,7 @@ export default {
|
||||||
},
|
},
|
||||||
coverImageField() {
|
coverImageField() {
|
||||||
const fieldId = this.view.card_cover_image_field
|
const fieldId = this.view.card_cover_image_field
|
||||||
return (
|
return this.fields.find((field) => field.id === fieldId) || null
|
||||||
[this.primary]
|
|
||||||
.concat(this.fields)
|
|
||||||
.find((field) => field.id === fieldId) || null
|
|
||||||
)
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
|
@ -358,7 +349,6 @@ export default {
|
||||||
{
|
{
|
||||||
table: this.table,
|
table: this.table,
|
||||||
fields: this.fields,
|
fields: this.fields,
|
||||||
primary: this.primary,
|
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|
|
@ -19,7 +19,6 @@
|
||||||
ref="updateContext"
|
ref="updateContext"
|
||||||
:option="option"
|
:option="option"
|
||||||
:fields="fields"
|
:fields="fields"
|
||||||
:primary="primary"
|
|
||||||
:store-prefix="storePrefix"
|
:store-prefix="storePrefix"
|
||||||
@saved="hide()"
|
@saved="hide()"
|
||||||
></KanbanViewUpdateStackContext>
|
></KanbanViewUpdateStackContext>
|
||||||
|
@ -79,10 +78,6 @@ export default {
|
||||||
type: Array,
|
type: Array,
|
||||||
required: true,
|
required: true,
|
||||||
},
|
},
|
||||||
primary: {
|
|
||||||
type: Object,
|
|
||||||
required: true,
|
|
||||||
},
|
|
||||||
storePrefix: {
|
storePrefix: {
|
||||||
type: String,
|
type: String,
|
||||||
required: true,
|
required: true,
|
||||||
|
@ -103,7 +98,6 @@ export default {
|
||||||
{
|
{
|
||||||
optionId: this.option.id,
|
optionId: this.option.id,
|
||||||
fields: this.fields,
|
fields: this.fields,
|
||||||
primary: this.primary,
|
|
||||||
deferredFieldUpdate: true,
|
deferredFieldUpdate: true,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
<ChooseSingleSelectField
|
<ChooseSingleSelectField
|
||||||
:view="view"
|
:view="view"
|
||||||
:table="table"
|
:table="table"
|
||||||
:fields="allFields"
|
:fields="fields"
|
||||||
:value="view.single_select_field"
|
:value="view.single_select_field"
|
||||||
:read-only="readOnly"
|
:read-only="readOnly"
|
||||||
:loading="loading"
|
:loading="loading"
|
||||||
|
@ -39,10 +39,6 @@ export default {
|
||||||
type: Array,
|
type: Array,
|
||||||
required: true,
|
required: true,
|
||||||
},
|
},
|
||||||
primary: {
|
|
||||||
type: Object,
|
|
||||||
required: true,
|
|
||||||
},
|
|
||||||
readOnly: {
|
readOnly: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
required: true,
|
required: true,
|
||||||
|
@ -58,11 +54,6 @@ export default {
|
||||||
loading: false,
|
loading: false,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
|
||||||
allFields() {
|
|
||||||
return [this.primary, ...this.fields]
|
|
||||||
},
|
|
||||||
},
|
|
||||||
methods: {
|
methods: {
|
||||||
async update(value) {
|
async update(value) {
|
||||||
this.loading = true
|
this.loading = true
|
||||||
|
|
|
@ -36,10 +36,6 @@ export default {
|
||||||
type: Array,
|
type: Array,
|
||||||
required: true,
|
required: true,
|
||||||
},
|
},
|
||||||
primary: {
|
|
||||||
type: Object,
|
|
||||||
required: true,
|
|
||||||
},
|
|
||||||
storePrefix: {
|
storePrefix: {
|
||||||
type: String,
|
type: String,
|
||||||
required: true,
|
required: true,
|
||||||
|
@ -60,7 +56,6 @@ export default {
|
||||||
{
|
{
|
||||||
optionId: this.option.id,
|
optionId: this.option.id,
|
||||||
fields: this.fields,
|
fields: this.fields,
|
||||||
primary: this.primary,
|
|
||||||
values,
|
values,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
|
@ -331,12 +331,11 @@ export const actions = {
|
||||||
*/
|
*/
|
||||||
async createNewRow(
|
async createNewRow(
|
||||||
{ dispatch, commit, getters },
|
{ dispatch, commit, getters },
|
||||||
{ view, table, fields, primary, values }
|
{ view, table, fields, values }
|
||||||
) {
|
) {
|
||||||
// First prepare an object that we can send to the
|
// First prepare an object that we can send to the
|
||||||
const allFields = [primary].concat(fields)
|
|
||||||
const preparedValues = {}
|
const preparedValues = {}
|
||||||
allFields.forEach((field) => {
|
fields.forEach((field) => {
|
||||||
const name = `field_${field.id}`
|
const name = `field_${field.id}`
|
||||||
const fieldType = this.$registry.get('field', field._.type.type)
|
const fieldType = this.$registry.get('field', field._.type.type)
|
||||||
|
|
||||||
|
@ -360,7 +359,6 @@ export const actions = {
|
||||||
view,
|
view,
|
||||||
values: data,
|
values: data,
|
||||||
fields,
|
fields,
|
||||||
primary,
|
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
|
@ -376,7 +374,7 @@ export const actions = {
|
||||||
*/
|
*/
|
||||||
async createdNewRow(
|
async createdNewRow(
|
||||||
{ dispatch, commit, getters, rootGetters },
|
{ dispatch, commit, getters, rootGetters },
|
||||||
{ view, values, fields, primary }
|
{ view, values, fields }
|
||||||
) {
|
) {
|
||||||
const row = clone(values)
|
const row = clone(values)
|
||||||
populateRow(row)
|
populateRow(row)
|
||||||
|
@ -385,7 +383,6 @@ export const actions = {
|
||||||
view,
|
view,
|
||||||
row,
|
row,
|
||||||
fields,
|
fields,
|
||||||
primary,
|
|
||||||
})
|
})
|
||||||
if (!matchesFilters) {
|
if (!matchesFilters) {
|
||||||
return
|
return
|
||||||
|
@ -398,7 +395,7 @@ export const actions = {
|
||||||
|
|
||||||
const sortedRows = clone(stack.results)
|
const sortedRows = clone(stack.results)
|
||||||
sortedRows.push(row)
|
sortedRows.push(row)
|
||||||
sortedRows.sort(getRowSortFunction(this.$registry, [], fields, primary))
|
sortedRows.sort(getRowSortFunction(this.$registry, [], fields))
|
||||||
const index = sortedRows.findIndex((r) => r.id === row.id)
|
const index = sortedRows.findIndex((r) => r.id === row.id)
|
||||||
const isLast = index === sortedRows.length - 1
|
const isLast = index === sortedRows.length - 1
|
||||||
|
|
||||||
|
@ -420,7 +417,7 @@ export const actions = {
|
||||||
*/
|
*/
|
||||||
async deletedExistingRow(
|
async deletedExistingRow(
|
||||||
{ dispatch, commit, getters },
|
{ dispatch, commit, getters },
|
||||||
{ view, row, fields, primary }
|
{ view, row, fields }
|
||||||
) {
|
) {
|
||||||
row = clone(row)
|
row = clone(row)
|
||||||
populateRow(row)
|
populateRow(row)
|
||||||
|
@ -429,7 +426,6 @@ export const actions = {
|
||||||
view,
|
view,
|
||||||
row,
|
row,
|
||||||
fields,
|
fields,
|
||||||
primary,
|
|
||||||
})
|
})
|
||||||
if (!matchesFilters) {
|
if (!matchesFilters) {
|
||||||
return
|
return
|
||||||
|
@ -456,7 +452,7 @@ export const actions = {
|
||||||
/**
|
/**
|
||||||
* Check if the provided row matches the provided view filters.
|
* Check if the provided row matches the provided view filters.
|
||||||
*/
|
*/
|
||||||
rowMatchesFilters(context, { view, fields, primary, row, overrides = {} }) {
|
rowMatchesFilters(context, { view, fields, row, overrides = {} }) {
|
||||||
const values = JSON.parse(JSON.stringify(row))
|
const values = JSON.parse(JSON.stringify(row))
|
||||||
Object.assign(values, overrides)
|
Object.assign(values, overrides)
|
||||||
|
|
||||||
|
@ -467,7 +463,7 @@ export const actions = {
|
||||||
this.$registry,
|
this.$registry,
|
||||||
view.filter_type,
|
view.filter_type,
|
||||||
view.filters,
|
view.filters,
|
||||||
primary === null ? fields : [primary, ...fields],
|
fields,
|
||||||
values
|
values
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
|
@ -479,7 +475,7 @@ export const actions = {
|
||||||
*/
|
*/
|
||||||
async updatedExistingRow(
|
async updatedExistingRow(
|
||||||
{ dispatch, getters, commit },
|
{ dispatch, getters, commit },
|
||||||
{ view, row, values, fields, primary }
|
{ view, row, values, fields }
|
||||||
) {
|
) {
|
||||||
const singleSelectFieldId = getters.getSingleSelectFieldId
|
const singleSelectFieldId = getters.getSingleSelectFieldId
|
||||||
const fieldName = `field_${singleSelectFieldId}`
|
const fieldName = `field_${singleSelectFieldId}`
|
||||||
|
@ -490,7 +486,6 @@ export const actions = {
|
||||||
view,
|
view,
|
||||||
row: oldRow,
|
row: oldRow,
|
||||||
fields,
|
fields,
|
||||||
primary,
|
|
||||||
})
|
})
|
||||||
const oldOption = oldRow[fieldName]
|
const oldOption = oldRow[fieldName]
|
||||||
const oldStackId = oldOption !== null ? oldOption.id : 'null'
|
const oldStackId = oldOption !== null ? oldOption.id : 'null'
|
||||||
|
@ -506,7 +501,6 @@ export const actions = {
|
||||||
view,
|
view,
|
||||||
row: newRow,
|
row: newRow,
|
||||||
fields,
|
fields,
|
||||||
primary,
|
|
||||||
})
|
})
|
||||||
const newOption = newRow[fieldName]
|
const newOption = newRow[fieldName]
|
||||||
const newStackId = newOption !== null ? newOption.id : 'null'
|
const newStackId = newOption !== null ? newOption.id : 'null'
|
||||||
|
@ -522,9 +516,7 @@ export const actions = {
|
||||||
}
|
}
|
||||||
newStackResults.push(newRow)
|
newStackResults.push(newRow)
|
||||||
newStackCount++
|
newStackCount++
|
||||||
newStackResults.sort(
|
newStackResults.sort(getRowSortFunction(this.$registry, [], fields))
|
||||||
getRowSortFunction(this.$registry, [], fields, primary)
|
|
||||||
)
|
|
||||||
const newIndex = newStackResults.findIndex((r) => r.id === newRow.id)
|
const newIndex = newStackResults.findIndex((r) => r.id === newRow.id)
|
||||||
const newIsLast = newIndex === newStackResults.length - 1
|
const newIsLast = newIndex === newStackResults.length - 1
|
||||||
const newExists =
|
const newExists =
|
||||||
|
@ -580,7 +572,7 @@ export const actions = {
|
||||||
* need to updated and will make a call to the backend. If something goes wrong,
|
* need to updated and will make a call to the backend. If something goes wrong,
|
||||||
* the row is moved back to the original stack and position.
|
* the row is moved back to the original stack and position.
|
||||||
*/
|
*/
|
||||||
async stopRowDrag({ dispatch, commit, getters }, { table, fields, primary }) {
|
async stopRowDrag({ dispatch, commit, getters }, { table, fields }) {
|
||||||
const row = getters.getDraggingRow
|
const row = getters.getDraggingRow
|
||||||
|
|
||||||
if (row === null) {
|
if (row === null) {
|
||||||
|
@ -601,9 +593,9 @@ export const actions = {
|
||||||
// We need to have the single select option field instance because we need
|
// We need to have the single select option field instance because we need
|
||||||
// access to the available options. We can figure that out by looking looping
|
// access to the available options. We can figure that out by looking looping
|
||||||
// over the provided fields.
|
// over the provided fields.
|
||||||
const singleSelectField = [primary]
|
const singleSelectField = fields.find(
|
||||||
.concat(fields)
|
(field) => field.id === getters.getSingleSelectFieldId
|
||||||
.find((field) => field.id === getters.getSingleSelectFieldId)
|
)
|
||||||
const singleSelectFieldType = this.$registry.get(
|
const singleSelectFieldType = this.$registry.get(
|
||||||
'field',
|
'field',
|
||||||
SingleSelectFieldType.getType()
|
SingleSelectFieldType.getType()
|
||||||
|
@ -755,10 +747,9 @@ export const actions = {
|
||||||
*/
|
*/
|
||||||
async updateRowValue(
|
async updateRowValue(
|
||||||
{ commit, dispatch },
|
{ commit, dispatch },
|
||||||
{ view, table, row, field, fields, primary, value, oldValue }
|
{ view, table, row, field, fields, value, oldValue }
|
||||||
) {
|
) {
|
||||||
const fieldType = this.$registry.get('field', field._.type.type)
|
const fieldType = this.$registry.get('field', field._.type.type)
|
||||||
const allFields = [primary].concat(fields)
|
|
||||||
const newValues = {}
|
const newValues = {}
|
||||||
const newValuesForUpdate = {}
|
const newValuesForUpdate = {}
|
||||||
const oldValues = {}
|
const oldValues = {}
|
||||||
|
@ -770,7 +761,7 @@ export const actions = {
|
||||||
)
|
)
|
||||||
oldValues[fieldName] = oldValue
|
oldValues[fieldName] = oldValue
|
||||||
|
|
||||||
allFields.forEach((fieldToCall) => {
|
fields.forEach((fieldToCall) => {
|
||||||
const fieldType = this.$registry.get('field', fieldToCall._.type.type)
|
const fieldType = this.$registry.get('field', fieldToCall._.type.type)
|
||||||
const fieldToCallName = `field_${fieldToCall.id}`
|
const fieldToCallName = `field_${fieldToCall.id}`
|
||||||
const currentFieldValue = row[fieldToCallName]
|
const currentFieldValue = row[fieldToCallName]
|
||||||
|
@ -791,7 +782,6 @@ export const actions = {
|
||||||
row,
|
row,
|
||||||
values: newValues,
|
values: newValues,
|
||||||
fields,
|
fields,
|
||||||
primary,
|
|
||||||
})
|
})
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -807,7 +797,6 @@ export const actions = {
|
||||||
row,
|
row,
|
||||||
values: oldValues,
|
values: oldValues,
|
||||||
fields,
|
fields,
|
||||||
primary,
|
|
||||||
})
|
})
|
||||||
throw error
|
throw error
|
||||||
}
|
}
|
||||||
|
@ -816,13 +805,10 @@ export const actions = {
|
||||||
* Creates a new stack by updating the related field option of the view's
|
* Creates a new stack by updating the related field option of the view's
|
||||||
* field. The values in the store also be updated accordingly.
|
* field. The values in the store also be updated accordingly.
|
||||||
*/
|
*/
|
||||||
async createStack(
|
async createStack({ getters, commit, dispatch }, { fields, color, value }) {
|
||||||
{ getters, commit, dispatch },
|
const field = fields.find(
|
||||||
{ fields, primary, color, value }
|
(field) => field.id === getters.getSingleSelectFieldId
|
||||||
) {
|
)
|
||||||
const field = [primary]
|
|
||||||
.concat(fields)
|
|
||||||
.find((field) => field.id === getters.getSingleSelectFieldId)
|
|
||||||
|
|
||||||
const updateValues = {
|
const updateValues = {
|
||||||
type: field.type,
|
type: field.type,
|
||||||
|
@ -868,11 +854,11 @@ export const actions = {
|
||||||
*/
|
*/
|
||||||
async updateStack(
|
async updateStack(
|
||||||
{ getters, commit, dispatch },
|
{ getters, commit, dispatch },
|
||||||
{ fields, primary, optionId, values }
|
{ fields, optionId, values }
|
||||||
) {
|
) {
|
||||||
const field = [primary]
|
const field = fields.find(
|
||||||
.concat(fields)
|
(field) => field.id === getters.getSingleSelectFieldId
|
||||||
.find((field) => field.id === getters.getSingleSelectFieldId)
|
)
|
||||||
|
|
||||||
const options = clone(field.select_options)
|
const options = clone(field.select_options)
|
||||||
const index = options.findIndex((o) => o.id === optionId)
|
const index = options.findIndex((o) => o.id === optionId)
|
||||||
|
@ -911,11 +897,11 @@ export const actions = {
|
||||||
*/
|
*/
|
||||||
async deleteStack(
|
async deleteStack(
|
||||||
{ getters, commit, dispatch },
|
{ getters, commit, dispatch },
|
||||||
{ fields, primary, optionId, deferredFieldUpdate = false }
|
{ fields, optionId, deferredFieldUpdate = false }
|
||||||
) {
|
) {
|
||||||
const field = [primary]
|
const field = fields.find(
|
||||||
.concat(fields)
|
(field) => field.id === getters.getSingleSelectFieldId
|
||||||
.find((field) => field.id === getters.getSingleSelectFieldId)
|
)
|
||||||
|
|
||||||
const options = clone(field.select_options)
|
const options = clone(field.select_options)
|
||||||
const index = options.findIndex((o) => o.id === optionId)
|
const index = options.findIndex((o) => o.id === optionId)
|
||||||
|
|
|
@ -54,7 +54,7 @@ export class KanbanViewType extends PremiumViewType {
|
||||||
return KanbanView
|
return KanbanView
|
||||||
}
|
}
|
||||||
|
|
||||||
async fetch({ store }, view, fields, primary, storePrefix = '') {
|
async fetch({ store }, view, fields, storePrefix = '') {
|
||||||
// If the single select field is `null` we can't fetch the initial data anyway,
|
// If the single select field is `null` we can't fetch the initial data anyway,
|
||||||
// we don't have to do anything. The KanbanView component will handle it by
|
// we don't have to do anything. The KanbanView component will handle it by
|
||||||
// showing a form to choose or create a single select field.
|
// showing a form to choose or create a single select field.
|
||||||
|
@ -72,7 +72,6 @@ export class KanbanViewType extends PremiumViewType {
|
||||||
{ store },
|
{ store },
|
||||||
view,
|
view,
|
||||||
fields,
|
fields,
|
||||||
primary,
|
|
||||||
storePrefix = '',
|
storePrefix = '',
|
||||||
includeFieldOptions = false
|
includeFieldOptions = false
|
||||||
) {
|
) {
|
||||||
|
@ -113,7 +112,6 @@ export class KanbanViewType extends PremiumViewType {
|
||||||
{ store },
|
{ store },
|
||||||
tableId,
|
tableId,
|
||||||
fields,
|
fields,
|
||||||
primary,
|
|
||||||
values,
|
values,
|
||||||
metadata,
|
metadata,
|
||||||
storePrefix = ''
|
storePrefix = ''
|
||||||
|
@ -121,9 +119,8 @@ export class KanbanViewType extends PremiumViewType {
|
||||||
if (this.isCurrentView(store, tableId)) {
|
if (this.isCurrentView(store, tableId)) {
|
||||||
await store.dispatch(storePrefix + 'view/kanban/createdNewRow', {
|
await store.dispatch(storePrefix + 'view/kanban/createdNewRow', {
|
||||||
view: store.getters['view/getSelected'],
|
view: store.getters['view/getSelected'],
|
||||||
fields,
|
|
||||||
primary,
|
|
||||||
values,
|
values,
|
||||||
|
fields,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -132,7 +129,6 @@ export class KanbanViewType extends PremiumViewType {
|
||||||
{ store },
|
{ store },
|
||||||
tableId,
|
tableId,
|
||||||
fields,
|
fields,
|
||||||
primary,
|
|
||||||
row,
|
row,
|
||||||
values,
|
values,
|
||||||
metadata,
|
metadata,
|
||||||
|
@ -142,20 +138,18 @@ export class KanbanViewType extends PremiumViewType {
|
||||||
await store.dispatch(storePrefix + 'view/kanban/updatedExistingRow', {
|
await store.dispatch(storePrefix + 'view/kanban/updatedExistingRow', {
|
||||||
view: store.getters['view/getSelected'],
|
view: store.getters['view/getSelected'],
|
||||||
fields,
|
fields,
|
||||||
primary,
|
|
||||||
row,
|
row,
|
||||||
values,
|
values,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async rowDeleted({ store }, tableId, fields, primary, row, storePrefix = '') {
|
async rowDeleted({ store }, tableId, fields, row, storePrefix = '') {
|
||||||
if (this.isCurrentView(store, tableId)) {
|
if (this.isCurrentView(store, tableId)) {
|
||||||
await store.dispatch(storePrefix + 'view/kanban/deletedExistingRow', {
|
await store.dispatch(storePrefix + 'view/kanban/deletedExistingRow', {
|
||||||
view: store.getters['view/getSelected'],
|
view: store.getters['view/getSelected'],
|
||||||
row,
|
row,
|
||||||
fields,
|
fields,
|
||||||
primary,
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,14 +40,6 @@ describe('Kanban view store', () => {
|
||||||
store.registerModule('kanban', kanbanStore)
|
store.registerModule('kanban', kanbanStore)
|
||||||
|
|
||||||
const fields = []
|
const fields = []
|
||||||
const primary = {
|
|
||||||
id: 1,
|
|
||||||
name: 'Single select',
|
|
||||||
type: 'single_select',
|
|
||||||
options: [{ id: 1, color: 'blue', value: '' }],
|
|
||||||
primary: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
await store.dispatch('kanban/createdNewRow', {
|
await store.dispatch('kanban/createdNewRow', {
|
||||||
view,
|
view,
|
||||||
values: {
|
values: {
|
||||||
|
@ -56,7 +48,6 @@ describe('Kanban view store', () => {
|
||||||
field_1: null,
|
field_1: null,
|
||||||
},
|
},
|
||||||
fields,
|
fields,
|
||||||
primary,
|
|
||||||
})
|
})
|
||||||
await store.dispatch('kanban/createdNewRow', {
|
await store.dispatch('kanban/createdNewRow', {
|
||||||
view,
|
view,
|
||||||
|
@ -66,7 +57,6 @@ describe('Kanban view store', () => {
|
||||||
field_1: null,
|
field_1: null,
|
||||||
},
|
},
|
||||||
fields,
|
fields,
|
||||||
primary,
|
|
||||||
})
|
})
|
||||||
|
|
||||||
expect(store.state.kanban.stacks.null.count).toBe(3)
|
expect(store.state.kanban.stacks.null.count).toBe(3)
|
||||||
|
@ -83,7 +73,6 @@ describe('Kanban view store', () => {
|
||||||
field_1: { id: 1 },
|
field_1: { id: 1 },
|
||||||
},
|
},
|
||||||
fields,
|
fields,
|
||||||
primary,
|
|
||||||
})
|
})
|
||||||
await store.dispatch('kanban/createdNewRow', {
|
await store.dispatch('kanban/createdNewRow', {
|
||||||
view,
|
view,
|
||||||
|
@ -93,7 +82,6 @@ describe('Kanban view store', () => {
|
||||||
field_1: { id: 1 },
|
field_1: { id: 1 },
|
||||||
},
|
},
|
||||||
fields,
|
fields,
|
||||||
primary,
|
|
||||||
})
|
})
|
||||||
|
|
||||||
expect(store.state.kanban.stacks['1'].count).toBe(102)
|
expect(store.state.kanban.stacks['1'].count).toBe(102)
|
||||||
|
@ -125,13 +113,6 @@ describe('Kanban view store', () => {
|
||||||
store.registerModule('kanban', kanbanStore)
|
store.registerModule('kanban', kanbanStore)
|
||||||
|
|
||||||
const fields = []
|
const fields = []
|
||||||
const primary = {
|
|
||||||
id: 1,
|
|
||||||
name: 'Single select',
|
|
||||||
type: 'single_select',
|
|
||||||
options: [{ id: 1, color: 'blue', value: '' }],
|
|
||||||
primary: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
await store.dispatch('kanban/deletedExistingRow', {
|
await store.dispatch('kanban/deletedExistingRow', {
|
||||||
view,
|
view,
|
||||||
|
@ -141,7 +122,6 @@ describe('Kanban view store', () => {
|
||||||
field_1: null,
|
field_1: null,
|
||||||
},
|
},
|
||||||
fields,
|
fields,
|
||||||
primary,
|
|
||||||
})
|
})
|
||||||
|
|
||||||
expect(store.state.kanban.stacks.null.count).toBe(0)
|
expect(store.state.kanban.stacks.null.count).toBe(0)
|
||||||
|
@ -155,7 +135,6 @@ describe('Kanban view store', () => {
|
||||||
field_1: { id: 1 },
|
field_1: { id: 1 },
|
||||||
},
|
},
|
||||||
fields,
|
fields,
|
||||||
primary,
|
|
||||||
})
|
})
|
||||||
await store.dispatch('kanban/deletedExistingRow', {
|
await store.dispatch('kanban/deletedExistingRow', {
|
||||||
view,
|
view,
|
||||||
|
@ -165,7 +144,6 @@ describe('Kanban view store', () => {
|
||||||
field_1: { id: 1 },
|
field_1: { id: 1 },
|
||||||
},
|
},
|
||||||
fields,
|
fields,
|
||||||
primary,
|
|
||||||
})
|
})
|
||||||
|
|
||||||
expect(store.state.kanban.stacks['1'].count).toBe(98)
|
expect(store.state.kanban.stacks['1'].count).toBe(98)
|
||||||
|
@ -200,13 +178,6 @@ describe('Kanban view store', () => {
|
||||||
store.registerModule('kanban', kanbanStore)
|
store.registerModule('kanban', kanbanStore)
|
||||||
|
|
||||||
const fields = []
|
const fields = []
|
||||||
const primary = {
|
|
||||||
id: 1,
|
|
||||||
name: 'Single select',
|
|
||||||
type: 'single_select',
|
|
||||||
options: [{ id: 1, color: 'blue', value: '' }],
|
|
||||||
primary: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
// Should be moved to the first in the buffer
|
// Should be moved to the first in the buffer
|
||||||
await store.dispatch('kanban/updatedExistingRow', {
|
await store.dispatch('kanban/updatedExistingRow', {
|
||||||
|
@ -216,7 +187,6 @@ describe('Kanban view store', () => {
|
||||||
order: '9.00',
|
order: '9.00',
|
||||||
},
|
},
|
||||||
fields,
|
fields,
|
||||||
primary,
|
|
||||||
})
|
})
|
||||||
// Should be completely ignored because it's outside of the buffer
|
// Should be completely ignored because it's outside of the buffer
|
||||||
await store.dispatch('kanban/updatedExistingRow', {
|
await store.dispatch('kanban/updatedExistingRow', {
|
||||||
|
@ -226,7 +196,6 @@ describe('Kanban view store', () => {
|
||||||
order: '13.00',
|
order: '13.00',
|
||||||
},
|
},
|
||||||
fields,
|
fields,
|
||||||
primary,
|
|
||||||
})
|
})
|
||||||
// Did not exist before, but has moved within the buffer.
|
// Did not exist before, but has moved within the buffer.
|
||||||
await store.dispatch('kanban/updatedExistingRow', {
|
await store.dispatch('kanban/updatedExistingRow', {
|
||||||
|
@ -236,7 +205,6 @@ describe('Kanban view store', () => {
|
||||||
order: '8.00',
|
order: '8.00',
|
||||||
},
|
},
|
||||||
fields,
|
fields,
|
||||||
primary,
|
|
||||||
})
|
})
|
||||||
|
|
||||||
expect(store.state.kanban.stacks['1'].count).toBe(101)
|
expect(store.state.kanban.stacks['1'].count).toBe(101)
|
||||||
|
@ -255,7 +223,6 @@ describe('Kanban view store', () => {
|
||||||
field_1: null,
|
field_1: null,
|
||||||
},
|
},
|
||||||
fields,
|
fields,
|
||||||
primary,
|
|
||||||
})
|
})
|
||||||
// Moved to stack `null`, because the position is within the buffer, we expect
|
// Moved to stack `null`, because the position is within the buffer, we expect
|
||||||
// it to be added to it.
|
// it to be added to it.
|
||||||
|
@ -267,7 +234,6 @@ describe('Kanban view store', () => {
|
||||||
order: '1.00',
|
order: '1.00',
|
||||||
},
|
},
|
||||||
fields,
|
fields,
|
||||||
primary,
|
|
||||||
})
|
})
|
||||||
|
|
||||||
expect(store.state.kanban.stacks.null.count).toBe(3)
|
expect(store.state.kanban.stacks.null.count).toBe(3)
|
||||||
|
@ -290,7 +256,6 @@ describe('Kanban view store', () => {
|
||||||
field_1: { id: 1 },
|
field_1: { id: 1 },
|
||||||
},
|
},
|
||||||
fields,
|
fields,
|
||||||
primary,
|
|
||||||
})
|
})
|
||||||
// Moved to stack `1`, because the position is outside the buffer, we expect it
|
// Moved to stack `1`, because the position is outside the buffer, we expect it
|
||||||
// not to be in there.
|
// not to be in there.
|
||||||
|
@ -301,7 +266,6 @@ describe('Kanban view store', () => {
|
||||||
field_1: { id: 1 },
|
field_1: { id: 1 },
|
||||||
},
|
},
|
||||||
fields,
|
fields,
|
||||||
primary,
|
|
||||||
})
|
})
|
||||||
|
|
||||||
expect(store.state.kanban.stacks.null.count).toBe(1)
|
expect(store.state.kanban.stacks.null.count).toBe(1)
|
||||||
|
|
|
@ -128,7 +128,7 @@ export default {
|
||||||
return this.defaultValues ? this.defaultValues.id : null
|
return this.defaultValues ? this.defaultValues.id : null
|
||||||
},
|
},
|
||||||
...mapGetters({
|
...mapGetters({
|
||||||
fields: 'field/getAllWithPrimary',
|
fields: 'field/getAll',
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
validations() {
|
validations() {
|
||||||
|
|
|
@ -69,7 +69,7 @@ export default {
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
...mapGetters({
|
...mapGetters({
|
||||||
rawFields: 'field/getAllWithPrimary',
|
rawFields: 'field/getAll',
|
||||||
}),
|
}),
|
||||||
localOrServerFormulaType() {
|
localOrServerFormulaType() {
|
||||||
return (
|
return (
|
||||||
|
|
|
@ -131,6 +131,7 @@ export default {
|
||||||
return {
|
return {
|
||||||
renaming: false,
|
renaming: false,
|
||||||
selected: 0,
|
selected: 0,
|
||||||
|
canClose: true,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
:table="table"
|
:table="table"
|
||||||
:rows="[]"
|
:rows="[]"
|
||||||
:visible-fields="fields"
|
:visible-fields="fields"
|
||||||
:primary="primary"
|
|
||||||
@hidden="$emit('hidden', $event)"
|
@hidden="$emit('hidden', $event)"
|
||||||
></RowEditModal>
|
></RowEditModal>
|
||||||
</template>
|
</template>
|
||||||
|
@ -37,7 +36,6 @@ export default {
|
||||||
fetchedTableAndFields: false,
|
fetchedTableAndFields: false,
|
||||||
table: {},
|
table: {},
|
||||||
fields: [],
|
fields: [],
|
||||||
primary: undefined,
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
@ -88,13 +86,7 @@ export default {
|
||||||
fieldData.forEach((part, index) => {
|
fieldData.forEach((part, index) => {
|
||||||
populateField(fieldData[index], this.$registry)
|
populateField(fieldData[index], this.$registry)
|
||||||
})
|
})
|
||||||
const primaryIndex = fieldData.findIndex((item) => item.primary === true)
|
this.fields = fieldData
|
||||||
if (primaryIndex !== -1) {
|
|
||||||
this.primary = fieldData.splice(primaryIndex, 1)[0]
|
|
||||||
this.fields = [this.primary, ...fieldData]
|
|
||||||
} else {
|
|
||||||
this.fields = fieldData
|
|
||||||
}
|
|
||||||
|
|
||||||
// Mark the table and fields as fetched, so that we don't have to do that a
|
// Mark the table and fields as fetched, so that we don't have to do that a
|
||||||
// second time when the user opens another row.
|
// second time when the user opens another row.
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<template>
|
<template>
|
||||||
<Modal ref="modal">
|
<Modal ref="modal">
|
||||||
<form @submit.prevent="create">
|
<form @submit.prevent="create">
|
||||||
<h2 v-if="primary !== undefined" class="box__title">
|
<h2 class="box__title">
|
||||||
{{ heading }}
|
{{ heading }}
|
||||||
</h2>
|
</h2>
|
||||||
<Error :error="error"></Error>
|
<Error :error="error"></Error>
|
||||||
|
@ -62,6 +62,7 @@ import modal from '@baserow/modules/core/mixins/modal'
|
||||||
import error from '@baserow/modules/core/mixins/error'
|
import error from '@baserow/modules/core/mixins/error'
|
||||||
import RowEditModalFieldsList from './RowEditModalFieldsList.vue'
|
import RowEditModalFieldsList from './RowEditModalFieldsList.vue'
|
||||||
import RowEditModalHiddenFieldsSection from './RowEditModalHiddenFieldsSection.vue'
|
import RowEditModalHiddenFieldsSection from './RowEditModalHiddenFieldsSection.vue'
|
||||||
|
import { getPrimaryOrFirstField } from '@baserow/modules/database/utils/field'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'RowCreateModal',
|
name: 'RowCreateModal',
|
||||||
|
@ -75,11 +76,6 @@ export default {
|
||||||
type: Object,
|
type: Object,
|
||||||
required: true,
|
required: true,
|
||||||
},
|
},
|
||||||
primary: {
|
|
||||||
type: Object,
|
|
||||||
required: false,
|
|
||||||
default: undefined,
|
|
||||||
},
|
|
||||||
primaryIsSortable: {
|
primaryIsSortable: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
required: false,
|
required: false,
|
||||||
|
@ -111,11 +107,17 @@ export default {
|
||||||
return this.visibleFields.concat(this.hiddenFields)
|
return this.visibleFields.concat(this.hiddenFields)
|
||||||
},
|
},
|
||||||
heading() {
|
heading() {
|
||||||
const name = `field_${this.primary.id}`
|
const field = getPrimaryOrFirstField(this.visibleFields)
|
||||||
|
|
||||||
|
if (!field) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
const name = `field_${field.id}`
|
||||||
if (Object.prototype.hasOwnProperty.call(this.row, name)) {
|
if (Object.prototype.hasOwnProperty.call(this.row, name)) {
|
||||||
return this.$registry
|
return this.$registry
|
||||||
.get('field', this.primary.type)
|
.get('field', field.type)
|
||||||
.toHumanReadableString(this.primary, this.row[name])
|
.toHumanReadableString(field, this.row[name])
|
||||||
} else {
|
} else {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,8 +8,8 @@
|
||||||
@hidden="$emit('hidden', { row })"
|
@hidden="$emit('hidden', { row })"
|
||||||
>
|
>
|
||||||
<template #content>
|
<template #content>
|
||||||
<h2 v-if="primary !== undefined" class="box__title">
|
<h2 class="box__title">
|
||||||
{{ getHeading(primary, row) }}
|
{{ heading }}
|
||||||
</h2>
|
</h2>
|
||||||
<RowEditModalFieldsList
|
<RowEditModalFieldsList
|
||||||
:primary-is-sortable="primaryIsSortable"
|
:primary-is-sortable="primaryIsSortable"
|
||||||
|
@ -80,6 +80,7 @@ import modal from '@baserow/modules/core/mixins/modal'
|
||||||
import CreateFieldContext from '@baserow/modules/database/components/field/CreateFieldContext'
|
import CreateFieldContext from '@baserow/modules/database/components/field/CreateFieldContext'
|
||||||
import RowEditModalFieldsList from './RowEditModalFieldsList.vue'
|
import RowEditModalFieldsList from './RowEditModalFieldsList.vue'
|
||||||
import RowEditModalHiddenFieldsSection from './RowEditModalHiddenFieldsSection.vue'
|
import RowEditModalHiddenFieldsSection from './RowEditModalHiddenFieldsSection.vue'
|
||||||
|
import { getPrimaryOrFirstField } from '@baserow/modules/database/utils/field'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'RowEditModal',
|
name: 'RowEditModal',
|
||||||
|
@ -92,17 +93,13 @@ export default {
|
||||||
props: {
|
props: {
|
||||||
database: {
|
database: {
|
||||||
type: Object,
|
type: Object,
|
||||||
required: true,
|
required: false,
|
||||||
|
default: null,
|
||||||
},
|
},
|
||||||
table: {
|
table: {
|
||||||
type: Object,
|
type: Object,
|
||||||
required: true,
|
required: true,
|
||||||
},
|
},
|
||||||
primary: {
|
|
||||||
type: Object,
|
|
||||||
required: false,
|
|
||||||
default: undefined,
|
|
||||||
},
|
|
||||||
primaryIsSortable: {
|
primaryIsSortable: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
required: false,
|
required: false,
|
||||||
|
@ -151,6 +148,22 @@ export default {
|
||||||
row() {
|
row() {
|
||||||
return this.modalRow.row
|
return this.modalRow.row
|
||||||
},
|
},
|
||||||
|
heading() {
|
||||||
|
const field = getPrimaryOrFirstField(this.visibleFields)
|
||||||
|
|
||||||
|
if (!field) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
const name = `field_${field.id}`
|
||||||
|
if (Object.prototype.hasOwnProperty.call(this.row, name)) {
|
||||||
|
return this.$registry
|
||||||
|
.get('field', field.type)
|
||||||
|
.toHumanReadableString(field, this.row[name])
|
||||||
|
} else {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
},
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
/**
|
/**
|
||||||
|
@ -208,16 +221,6 @@ export default {
|
||||||
context.table = this.table
|
context.table = this.table
|
||||||
this.$emit('update', context)
|
this.$emit('update', context)
|
||||||
},
|
},
|
||||||
getHeading(primary, row) {
|
|
||||||
const name = `field_${primary.id}`
|
|
||||||
if (Object.prototype.hasOwnProperty.call(row, name)) {
|
|
||||||
return this.$registry
|
|
||||||
.get('field', primary.type)
|
|
||||||
.toHumanReadableString(primary, row[name])
|
|
||||||
} else {
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -80,7 +80,6 @@
|
||||||
<ViewFilter
|
<ViewFilter
|
||||||
:view="view"
|
:view="view"
|
||||||
:fields="fields"
|
:fields="fields"
|
||||||
:primary="primary"
|
|
||||||
:read-only="readOnly"
|
:read-only="readOnly"
|
||||||
:disable-filter="disableFilter"
|
:disable-filter="disableFilter"
|
||||||
@changed="refresh()"
|
@changed="refresh()"
|
||||||
|
@ -93,7 +92,6 @@
|
||||||
<ViewSort
|
<ViewSort
|
||||||
:view="view"
|
:view="view"
|
||||||
:fields="fields"
|
:fields="fields"
|
||||||
:primary="primary"
|
|
||||||
:read-only="readOnly"
|
:read-only="readOnly"
|
||||||
:disable-sort="disableSort"
|
:disable-sort="disableSort"
|
||||||
@changed="refresh()"
|
@changed="refresh()"
|
||||||
|
@ -114,7 +112,6 @@
|
||||||
:view="view"
|
:view="view"
|
||||||
:table="table"
|
:table="table"
|
||||||
:fields="fields"
|
:fields="fields"
|
||||||
:primary="primary"
|
|
||||||
:read-only="readOnly"
|
:read-only="readOnly"
|
||||||
:disable-sort="disableSort"
|
:disable-sort="disableSort"
|
||||||
@changed="refresh()"
|
@changed="refresh()"
|
||||||
|
@ -128,7 +125,6 @@
|
||||||
:table="table"
|
:table="table"
|
||||||
:view="view"
|
:view="view"
|
||||||
:fields="fields"
|
:fields="fields"
|
||||||
:primary="primary"
|
|
||||||
:read-only="readOnly"
|
:read-only="readOnly"
|
||||||
:store-prefix="storePrefix"
|
:store-prefix="storePrefix"
|
||||||
@refresh="refresh"
|
@refresh="refresh"
|
||||||
|
@ -143,7 +139,6 @@
|
||||||
:table="table"
|
:table="table"
|
||||||
:view="view"
|
:view="view"
|
||||||
:fields="fields"
|
:fields="fields"
|
||||||
:primary="primary"
|
|
||||||
:read-only="readOnly"
|
:read-only="readOnly"
|
||||||
:store-prefix="storePrefix"
|
:store-prefix="storePrefix"
|
||||||
@refresh="refresh"
|
@refresh="refresh"
|
||||||
|
@ -202,10 +197,6 @@ export default {
|
||||||
type: Array,
|
type: Array,
|
||||||
required: true,
|
required: true,
|
||||||
},
|
},
|
||||||
primary: {
|
|
||||||
type: Object,
|
|
||||||
required: true,
|
|
||||||
},
|
|
||||||
views: {
|
views: {
|
||||||
required: false,
|
required: false,
|
||||||
validator: (prop) => typeof prop === 'object' || prop === undefined,
|
validator: (prop) => typeof prop === 'object' || prop === undefined,
|
||||||
|
@ -349,7 +340,6 @@ export default {
|
||||||
{ store: this.$store },
|
{ store: this.$store },
|
||||||
this.view,
|
this.view,
|
||||||
fieldsToRefresh,
|
fieldsToRefresh,
|
||||||
this.primary,
|
|
||||||
this.storePrefix,
|
this.storePrefix,
|
||||||
includeFieldOptions
|
includeFieldOptions
|
||||||
)
|
)
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
:database="database"
|
:database="database"
|
||||||
:table="table"
|
:table="table"
|
||||||
:fields="fields"
|
:fields="fields"
|
||||||
:primary="primary"
|
|
||||||
:views="views"
|
:views="views"
|
||||||
:view="view"
|
:view="view"
|
||||||
:table-loading="tableLoading"
|
:table-loading="tableLoading"
|
||||||
|
@ -38,7 +37,6 @@ export default {
|
||||||
database: {},
|
database: {},
|
||||||
table: {},
|
table: {},
|
||||||
fields: [],
|
fields: [],
|
||||||
primary: {},
|
|
||||||
views: [],
|
views: [],
|
||||||
view: {},
|
view: {},
|
||||||
tableLoading: true,
|
tableLoading: true,
|
||||||
|
@ -86,13 +84,7 @@ export default {
|
||||||
fieldsData.forEach((part, index, d) => {
|
fieldsData.forEach((part, index, d) => {
|
||||||
populateField(fieldsData[index], this.$registry)
|
populateField(fieldsData[index], this.$registry)
|
||||||
})
|
})
|
||||||
const primaryIndex = fieldsData.findIndex(
|
|
||||||
(item) => item.primary === true
|
|
||||||
)
|
|
||||||
const primary =
|
|
||||||
primaryIndex !== -1 ? fieldsData.splice(primaryIndex, 1)[0] : null
|
|
||||||
this.fields = fieldsData
|
this.fields = fieldsData
|
||||||
this.primary = primary
|
|
||||||
|
|
||||||
// Fetch and prepare the views of the given table.
|
// Fetch and prepare the views of the given table.
|
||||||
const { data: viewsData } = await ViewService(this.$client).fetchAll(
|
const { data: viewsData } = await ViewService(this.$client).fetchAll(
|
||||||
|
@ -153,7 +145,7 @@ export default {
|
||||||
{ store: this.$store },
|
{ store: this.$store },
|
||||||
view,
|
view,
|
||||||
this.fields,
|
this.fields,
|
||||||
this.primary,
|
null,
|
||||||
'template/'
|
'template/'
|
||||||
)
|
)
|
||||||
this.tableLoading = false
|
this.tableLoading = false
|
||||||
|
|
|
@ -60,7 +60,6 @@
|
||||||
v-if="dec.valueProviderType"
|
v-if="dec.valueProviderType"
|
||||||
:view="view"
|
:view="view"
|
||||||
:table="table"
|
:table="table"
|
||||||
:primary="primary"
|
|
||||||
:fields="fields"
|
:fields="fields"
|
||||||
:read-only="readOnly"
|
:read-only="readOnly"
|
||||||
:options="dec.decoration.value_provider_conf"
|
:options="dec.decoration.value_provider_conf"
|
||||||
|
@ -129,10 +128,6 @@ export default {
|
||||||
type: Object,
|
type: Object,
|
||||||
required: true,
|
required: true,
|
||||||
},
|
},
|
||||||
primary: {
|
|
||||||
type: Object,
|
|
||||||
required: true,
|
|
||||||
},
|
|
||||||
fields: {
|
fields: {
|
||||||
type: Array,
|
type: Array,
|
||||||
required: true,
|
required: true,
|
||||||
|
@ -173,7 +168,7 @@ export default {
|
||||||
value_provider_type: valueProviderType.getType(),
|
value_provider_type: valueProviderType.getType(),
|
||||||
value_provider_conf: valueProviderType.getDefaultConfiguration({
|
value_provider_conf: valueProviderType.getDefaultConfiguration({
|
||||||
view: this.view,
|
view: this.view,
|
||||||
fields: this.allTableFields,
|
fields: this.fields,
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
decoration,
|
decoration,
|
||||||
|
|
|
@ -21,7 +21,6 @@
|
||||||
:view="view"
|
:view="view"
|
||||||
:table="table"
|
:table="table"
|
||||||
:fields="fields"
|
:fields="fields"
|
||||||
:primary="primary"
|
|
||||||
:read-only="readOnly"
|
:read-only="readOnly"
|
||||||
@changed="$emit('changed')"
|
@changed="$emit('changed')"
|
||||||
></ViewDecoratorContext>
|
></ViewDecoratorContext>
|
||||||
|
@ -39,10 +38,6 @@ export default {
|
||||||
type: Object,
|
type: Object,
|
||||||
required: true,
|
required: true,
|
||||||
},
|
},
|
||||||
primary: {
|
|
||||||
type: Object,
|
|
||||||
required: true,
|
|
||||||
},
|
|
||||||
fields: {
|
fields: {
|
||||||
type: Array,
|
type: Array,
|
||||||
required: true,
|
required: true,
|
||||||
|
|
|
@ -51,12 +51,6 @@
|
||||||
class="dropdown--floating dropdown--tiny"
|
class="dropdown--floating dropdown--tiny"
|
||||||
@input="updateFilter(filter, { field: $event })"
|
@input="updateFilter(filter, { field: $event })"
|
||||||
>
|
>
|
||||||
<DropdownItem
|
|
||||||
:key="'primary-' + primary.id"
|
|
||||||
:name="primary.name"
|
|
||||||
:value="primary.id"
|
|
||||||
:disabled="hasNoCompatibleFilterTypes(primary, filterTypes)"
|
|
||||||
></DropdownItem>
|
|
||||||
<DropdownItem
|
<DropdownItem
|
||||||
v-for="field in fields"
|
v-for="field in fields"
|
||||||
:key="'field-' + field.id"
|
:key="'field-' + field.id"
|
||||||
|
@ -74,12 +68,7 @@
|
||||||
@input="updateFilter(filter, { type: $event })"
|
@input="updateFilter(filter, { type: $event })"
|
||||||
>
|
>
|
||||||
<DropdownItem
|
<DropdownItem
|
||||||
v-for="fType in allowedFilters(
|
v-for="fType in allowedFilters(filterTypes, fields, filter.field)"
|
||||||
filterTypes,
|
|
||||||
primary,
|
|
||||||
fields,
|
|
||||||
filter.field
|
|
||||||
)"
|
|
||||||
:key="fType.type"
|
:key="fType.type"
|
||||||
:name="fType.getName()"
|
:name="fType.getName()"
|
||||||
:value="fType.type"
|
:value="fType.type"
|
||||||
|
@ -93,7 +82,6 @@
|
||||||
:filter="filter"
|
:filter="filter"
|
||||||
:view="view"
|
:view="view"
|
||||||
:fields="fields"
|
:fields="fields"
|
||||||
:primary="primary"
|
|
||||||
:disabled="disableFilter"
|
:disabled="disableFilter"
|
||||||
:read-only="readOnly"
|
:read-only="readOnly"
|
||||||
@input="updateFilter(filter, { value: $event })"
|
@input="updateFilter(filter, { value: $event })"
|
||||||
|
@ -119,10 +107,6 @@ export default {
|
||||||
type: String,
|
type: String,
|
||||||
required: true,
|
required: true,
|
||||||
},
|
},
|
||||||
primary: {
|
|
||||||
type: Object,
|
|
||||||
required: true,
|
|
||||||
},
|
|
||||||
fields: {
|
fields: {
|
||||||
type: Array,
|
type: Array,
|
||||||
required: true,
|
required: true,
|
||||||
|
@ -184,9 +168,8 @@ export default {
|
||||||
/**
|
/**
|
||||||
* Returns a list of filter types that are allowed for the given fieldId.
|
* Returns a list of filter types that are allowed for the given fieldId.
|
||||||
*/
|
*/
|
||||||
allowedFilters(filterTypes, primary, fields, fieldId) {
|
allowedFilters(filterTypes, fields, fieldId) {
|
||||||
const field =
|
const field = fields.find((f) => f.id === fieldId)
|
||||||
primary.id === fieldId ? primary : fields.find((f) => f.id === fieldId)
|
|
||||||
return Object.values(filterTypes).filter((filterType) => {
|
return Object.values(filterTypes).filter((filterType) => {
|
||||||
return field !== undefined && filterType.fieldIsCompatible(field)
|
return field !== undefined && filterType.fieldIsCompatible(field)
|
||||||
})
|
})
|
||||||
|
@ -214,7 +197,6 @@ export default {
|
||||||
if (Object.prototype.hasOwnProperty.call(values, 'field')) {
|
if (Object.prototype.hasOwnProperty.call(values, 'field')) {
|
||||||
const allowedFilterTypes = this.allowedFilters(
|
const allowedFilterTypes = this.allowedFilters(
|
||||||
this.filterTypes,
|
this.filterTypes,
|
||||||
this.primary,
|
|
||||||
this.fields,
|
this.fields,
|
||||||
field
|
field
|
||||||
).map((filter) => filter.type)
|
).map((filter) => filter.type)
|
||||||
|
@ -244,10 +226,7 @@ export default {
|
||||||
* responsible for updating the filter value.
|
* responsible for updating the filter value.
|
||||||
*/
|
*/
|
||||||
getInputComponent(type, fieldId) {
|
getInputComponent(type, fieldId) {
|
||||||
const field =
|
const field = this.fields.find(({ id }) => id === fieldId)
|
||||||
this.primary.id === fieldId
|
|
||||||
? this.primary
|
|
||||||
: this.fields.find(({ id }) => id === fieldId)
|
|
||||||
return this.$registry.get('viewFilter', type).getInputComponent(field)
|
return this.$registry.get('viewFilter', type).getInputComponent(field)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
@ -21,7 +21,6 @@
|
||||||
:class="{ 'context--loading-overlay': view._.loading }"
|
:class="{ 'context--loading-overlay': view._.loading }"
|
||||||
>
|
>
|
||||||
<ViewFilterForm
|
<ViewFilterForm
|
||||||
:primary="primary"
|
|
||||||
:fields="fields"
|
:fields="fields"
|
||||||
:view="view"
|
:view="view"
|
||||||
:read-only="readOnly"
|
:read-only="readOnly"
|
||||||
|
@ -39,10 +38,6 @@ export default {
|
||||||
name: 'ViewFilter',
|
name: 'ViewFilter',
|
||||||
components: { ViewFilterForm },
|
components: { ViewFilterForm },
|
||||||
props: {
|
props: {
|
||||||
primary: {
|
|
||||||
type: Object,
|
|
||||||
required: true,
|
|
||||||
},
|
|
||||||
fields: {
|
fields: {
|
||||||
type: Array,
|
type: Array,
|
||||||
required: true,
|
required: true,
|
||||||
|
|
|
@ -14,7 +14,6 @@
|
||||||
:filters="view.filters"
|
:filters="view.filters"
|
||||||
:disable-filter="disableFilter"
|
:disable-filter="disableFilter"
|
||||||
:filter-type="view.filter_type"
|
:filter-type="view.filter_type"
|
||||||
:primary="primary"
|
|
||||||
:fields="fields"
|
:fields="fields"
|
||||||
:view="view"
|
:view="view"
|
||||||
:read-only="readOnly"
|
:read-only="readOnly"
|
||||||
|
@ -42,6 +41,7 @@
|
||||||
<script>
|
<script>
|
||||||
import { notifyIf } from '@baserow/modules/core/utils/error'
|
import { notifyIf } from '@baserow/modules/core/utils/error'
|
||||||
import ViewFieldConditionsForm from '@baserow/modules/database/components/view/ViewFieldConditionsForm'
|
import ViewFieldConditionsForm from '@baserow/modules/database/components/view/ViewFieldConditionsForm'
|
||||||
|
import { getPrimaryOrFirstField } from '@baserow/modules/database/utils/field'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'ViewFilterForm',
|
name: 'ViewFilterForm',
|
||||||
|
@ -49,10 +49,6 @@ export default {
|
||||||
ViewFieldConditionsForm,
|
ViewFieldConditionsForm,
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
primary: {
|
|
||||||
type: Object,
|
|
||||||
required: true,
|
|
||||||
},
|
|
||||||
fields: {
|
fields: {
|
||||||
type: Array,
|
type: Array,
|
||||||
required: true,
|
required: true,
|
||||||
|
@ -78,11 +74,12 @@ export default {
|
||||||
methods: {
|
methods: {
|
||||||
async addFilter(values) {
|
async addFilter(values) {
|
||||||
try {
|
try {
|
||||||
|
const field = getPrimaryOrFirstField(this.fields)
|
||||||
await this.$store.dispatch('view/createFilter', {
|
await this.$store.dispatch('view/createFilter', {
|
||||||
|
field,
|
||||||
view: this.view,
|
view: this.view,
|
||||||
field: this.primary,
|
|
||||||
values: {
|
values: {
|
||||||
field: this.primary.id,
|
field: field.id,
|
||||||
},
|
},
|
||||||
emitEvent: false,
|
emitEvent: false,
|
||||||
readOnly: this.readOnly,
|
readOnly: this.readOnly,
|
||||||
|
|
|
@ -28,10 +28,6 @@ export default {
|
||||||
type: Array,
|
type: Array,
|
||||||
required: true,
|
required: true,
|
||||||
},
|
},
|
||||||
primary: {
|
|
||||||
type: Object,
|
|
||||||
required: true,
|
|
||||||
},
|
|
||||||
readOnly: {
|
readOnly: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
required: true,
|
required: true,
|
||||||
|
|
|
@ -15,7 +15,6 @@
|
||||||
ref="context"
|
ref="context"
|
||||||
:view="view"
|
:view="view"
|
||||||
:fields="fields"
|
:fields="fields"
|
||||||
:primary="primary"
|
|
||||||
:store-prefix="storePrefix"
|
:store-prefix="storePrefix"
|
||||||
:always-hide-rows-not-matching-search="alwaysHideRowsNotMatchingSearch"
|
:always-hide-rows-not-matching-search="alwaysHideRowsNotMatchingSearch"
|
||||||
@refresh="$emit('refresh', $event)"
|
@refresh="$emit('refresh', $event)"
|
||||||
|
@ -39,10 +38,6 @@ export default {
|
||||||
type: Array,
|
type: Array,
|
||||||
required: true,
|
required: true,
|
||||||
},
|
},
|
||||||
primary: {
|
|
||||||
type: Object,
|
|
||||||
required: true,
|
|
||||||
},
|
|
||||||
storePrefix: {
|
storePrefix: {
|
||||||
type: String,
|
type: String,
|
||||||
required: true,
|
required: true,
|
||||||
|
|
|
@ -54,10 +54,6 @@ export default {
|
||||||
type: Array,
|
type: Array,
|
||||||
required: true,
|
required: true,
|
||||||
},
|
},
|
||||||
primary: {
|
|
||||||
type: Object,
|
|
||||||
required: true,
|
|
||||||
},
|
|
||||||
storePrefix: {
|
storePrefix: {
|
||||||
type: String,
|
type: String,
|
||||||
required: true,
|
required: true,
|
||||||
|
@ -120,7 +116,6 @@ export default {
|
||||||
// the server using the newly set search terms.
|
// the server using the newly set search terms.
|
||||||
refreshMatchesOnClient: false,
|
refreshMatchesOnClient: false,
|
||||||
fields: this.fields,
|
fields: this.fields,
|
||||||
primary: this.primary,
|
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
this.$emit('refresh', {
|
this.$emit('refresh', {
|
||||||
|
@ -137,7 +132,6 @@ export default {
|
||||||
hideRowsNotMatchingSearch: this.hideRowsNotMatchingSearch,
|
hideRowsNotMatchingSearch: this.hideRowsNotMatchingSearch,
|
||||||
refreshMatchesOnClient: true,
|
refreshMatchesOnClient: true,
|
||||||
fields: this.fields,
|
fields: this.fields,
|
||||||
primary: this.primary,
|
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
this.finishedLoading()
|
this.finishedLoading()
|
||||||
|
|
|
@ -19,7 +19,6 @@
|
||||||
ref="context"
|
ref="context"
|
||||||
:view="view"
|
:view="view"
|
||||||
:fields="fields"
|
:fields="fields"
|
||||||
:primary="primary"
|
|
||||||
:read-only="readOnly"
|
:read-only="readOnly"
|
||||||
:disable-sort="disableSort"
|
:disable-sort="disableSort"
|
||||||
@changed="$emit('changed')"
|
@changed="$emit('changed')"
|
||||||
|
@ -34,10 +33,6 @@ export default {
|
||||||
name: 'ViewSort',
|
name: 'ViewSort',
|
||||||
components: { ViewSortContext },
|
components: { ViewSortContext },
|
||||||
props: {
|
props: {
|
||||||
primary: {
|
|
||||||
type: Object,
|
|
||||||
required: true,
|
|
||||||
},
|
|
||||||
fields: {
|
fields: {
|
||||||
type: Array,
|
type: Array,
|
||||||
required: true,
|
required: true,
|
||||||
|
|
|
@ -40,14 +40,6 @@
|
||||||
class="dropdown--floating dropdown--tiny"
|
class="dropdown--floating dropdown--tiny"
|
||||||
@input="updateSort(sort, { field: $event })"
|
@input="updateSort(sort, { field: $event })"
|
||||||
>
|
>
|
||||||
<DropdownItem
|
|
||||||
:key="'sort-field-' + sort.id + '-' + primary.id"
|
|
||||||
:name="primary.name"
|
|
||||||
:value="primary.id"
|
|
||||||
:disabled="
|
|
||||||
sort.field !== primary.id && !isFieldAvailable(primary)
|
|
||||||
"
|
|
||||||
></DropdownItem>
|
|
||||||
<DropdownItem
|
<DropdownItem
|
||||||
v-for="field in fields"
|
v-for="field in fields"
|
||||||
:key="'sort-field-' + sort.id + '-' + field.id"
|
:key="'sort-field-' + sort.id + '-' + field.id"
|
||||||
|
@ -136,15 +128,6 @@
|
||||||
</a>
|
</a>
|
||||||
<Context ref="addContext" class="sortings__add-context">
|
<Context ref="addContext" class="sortings__add-context">
|
||||||
<ul ref="items" class="context__menu">
|
<ul ref="items" class="context__menu">
|
||||||
<li v-show="isFieldAvailable(primary)">
|
|
||||||
<a @click="addSort(primary)">
|
|
||||||
<i
|
|
||||||
class="context__menu-icon fas fa-fw"
|
|
||||||
:class="'fa-' + primary._.type.iconClass"
|
|
||||||
></i>
|
|
||||||
{{ primary.name }}
|
|
||||||
</a>
|
|
||||||
</li>
|
|
||||||
<li
|
<li
|
||||||
v-for="field in fields"
|
v-for="field in fields"
|
||||||
v-show="isFieldAvailable(field)"
|
v-show="isFieldAvailable(field)"
|
||||||
|
@ -173,10 +156,6 @@ export default {
|
||||||
name: 'ViewSortContext',
|
name: 'ViewSortContext',
|
||||||
mixins: [context],
|
mixins: [context],
|
||||||
props: {
|
props: {
|
||||||
primary: {
|
|
||||||
type: Object,
|
|
||||||
required: true,
|
|
||||||
},
|
|
||||||
fields: {
|
fields: {
|
||||||
type: Array,
|
type: Array,
|
||||||
required: true,
|
required: true,
|
||||||
|
@ -204,11 +183,7 @@ export default {
|
||||||
* Calculates the total amount of available fields.
|
* Calculates the total amount of available fields.
|
||||||
*/
|
*/
|
||||||
availableFieldsLength() {
|
availableFieldsLength() {
|
||||||
const fields = this.fields.filter((field) =>
|
return this.fields.filter(this.getCanSortInView).length
|
||||||
this.getCanSortInView(field)
|
|
||||||
).length
|
|
||||||
const primary = this.getCanSortInView(this.primary) ? 1 : 0
|
|
||||||
return fields + primary
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
@ -216,9 +191,6 @@ export default {
|
||||||
return this.$registry.get('field', field.type).getCanSortInView(field)
|
return this.$registry.get('field', field.type).getCanSortInView(field)
|
||||||
},
|
},
|
||||||
getField(fieldId) {
|
getField(fieldId) {
|
||||||
if (this.primary.id === fieldId) {
|
|
||||||
return this.primary
|
|
||||||
}
|
|
||||||
for (const i in this.fields) {
|
for (const i in this.fields) {
|
||||||
if (this.fields[i].id === fieldId) {
|
if (this.fields[i].id === fieldId) {
|
||||||
return this.fields[i]
|
return this.fields[i]
|
||||||
|
|
|
@ -33,10 +33,6 @@ export default {
|
||||||
components: { FormViewSidebar, FormViewPreview },
|
components: { FormViewSidebar, FormViewPreview },
|
||||||
mixins: [formViewHelpers],
|
mixins: [formViewHelpers],
|
||||||
props: {
|
props: {
|
||||||
primary: {
|
|
||||||
type: Object,
|
|
||||||
required: true,
|
|
||||||
},
|
|
||||||
fields: {
|
fields: {
|
||||||
type: Array,
|
type: Array,
|
||||||
required: true,
|
required: true,
|
||||||
|
@ -61,7 +57,6 @@ export default {
|
||||||
computed: {
|
computed: {
|
||||||
sortedFields() {
|
sortedFields() {
|
||||||
const fields = this.fields.slice()
|
const fields = this.fields.slice()
|
||||||
fields.unshift(this.primary)
|
|
||||||
return fields.sort((a, b) => {
|
return fields.sort((a, b) => {
|
||||||
const orderA = this.getFieldOption(a.id, 'order', maxPossibleOrderValue)
|
const orderA = this.getFieldOption(a.id, 'order', maxPossibleOrderValue)
|
||||||
const orderB = this.getFieldOption(b.id, 'order', maxPossibleOrderValue)
|
const orderB = this.getFieldOption(b.id, 'order', maxPossibleOrderValue)
|
||||||
|
|
|
@ -31,10 +31,6 @@ export default {
|
||||||
type: Array,
|
type: Array,
|
||||||
required: true,
|
required: true,
|
||||||
},
|
},
|
||||||
primary: {
|
|
||||||
type: Object,
|
|
||||||
required: true,
|
|
||||||
},
|
|
||||||
readOnly: {
|
readOnly: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
required: true,
|
required: true,
|
||||||
|
|
|
@ -56,7 +56,6 @@
|
||||||
v-if="!readOnly"
|
v-if="!readOnly"
|
||||||
ref="rowCreateModal"
|
ref="rowCreateModal"
|
||||||
:table="table"
|
:table="table"
|
||||||
:primary="primary"
|
|
||||||
:primary-is-sortable="true"
|
:primary-is-sortable="true"
|
||||||
:visible-fields="cardFields"
|
:visible-fields="cardFields"
|
||||||
:hidden-fields="hiddenFields"
|
:hidden-fields="hiddenFields"
|
||||||
|
@ -74,7 +73,6 @@
|
||||||
ref="rowEditModal"
|
ref="rowEditModal"
|
||||||
:database="database"
|
:database="database"
|
||||||
:table="table"
|
:table="table"
|
||||||
:primary="primary"
|
|
||||||
:primary-is-sortable="true"
|
:primary-is-sortable="true"
|
||||||
:visible-fields="cardFields"
|
:visible-fields="cardFields"
|
||||||
:hidden-fields="hiddenFields"
|
:hidden-fields="hiddenFields"
|
||||||
|
@ -123,10 +121,6 @@ export default {
|
||||||
components: { RowCard, RowCreateModal, RowEditModal },
|
components: { RowCard, RowCreateModal, RowEditModal },
|
||||||
mixins: [viewHelpers, bufferedRowsDragAndDrop, viewDecoration],
|
mixins: [viewHelpers, bufferedRowsDragAndDrop, viewDecoration],
|
||||||
props: {
|
props: {
|
||||||
primary: {
|
|
||||||
type: Object,
|
|
||||||
required: true,
|
|
||||||
},
|
|
||||||
fields: {
|
fields: {
|
||||||
type: Array,
|
type: Array,
|
||||||
required: true,
|
required: true,
|
||||||
|
@ -183,25 +177,19 @@ export default {
|
||||||
*/
|
*/
|
||||||
cardFields() {
|
cardFields() {
|
||||||
const fieldOptions = this.fieldOptions
|
const fieldOptions = this.fieldOptions
|
||||||
return [this.primary]
|
return this.fields
|
||||||
.concat(this.fields)
|
|
||||||
.filter(filterVisibleFieldsFunction(fieldOptions))
|
.filter(filterVisibleFieldsFunction(fieldOptions))
|
||||||
.sort(sortFieldsByOrderAndIdFunction(fieldOptions))
|
.sort(sortFieldsByOrderAndIdFunction(fieldOptions))
|
||||||
},
|
},
|
||||||
hiddenFields() {
|
hiddenFields() {
|
||||||
const fieldOptions = this.fieldOptions
|
const fieldOptions = this.fieldOptions
|
||||||
return [this.primary]
|
return this.fields
|
||||||
.concat(this.fields)
|
|
||||||
.filter(filterHiddenFieldsFunction(fieldOptions))
|
.filter(filterHiddenFieldsFunction(fieldOptions))
|
||||||
.sort(sortFieldsByOrderAndIdFunction(fieldOptions))
|
.sort(sortFieldsByOrderAndIdFunction(fieldOptions))
|
||||||
},
|
},
|
||||||
coverImageField() {
|
coverImageField() {
|
||||||
const fieldId = this.view.card_cover_image_field
|
const fieldId = this.view.card_cover_image_field
|
||||||
return (
|
return this.fields.find((field) => field.id === fieldId) || null
|
||||||
[this.primary]
|
|
||||||
.concat(this.fields)
|
|
||||||
.find((field) => field.id === fieldId) || null
|
|
||||||
)
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
|
@ -373,7 +361,6 @@ export default {
|
||||||
view: this.view,
|
view: this.view,
|
||||||
table: this.table,
|
table: this.table,
|
||||||
fields: this.fields,
|
fields: this.fields,
|
||||||
primary: this.primary,
|
|
||||||
values: row,
|
values: row,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
@ -390,7 +377,6 @@ export default {
|
||||||
table: this.table,
|
table: this.table,
|
||||||
view: this.view,
|
view: this.view,
|
||||||
fields: this.fields,
|
fields: this.fields,
|
||||||
primary: this.primary,
|
|
||||||
row,
|
row,
|
||||||
field,
|
field,
|
||||||
value,
|
value,
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
</a>
|
</a>
|
||||||
<ViewFieldsContext
|
<ViewFieldsContext
|
||||||
ref="customizeContext"
|
ref="customizeContext"
|
||||||
:fields="allFields"
|
:fields="fields"
|
||||||
:read-only="readOnly"
|
:read-only="readOnly"
|
||||||
:field-options="fieldOptions"
|
:field-options="fieldOptions"
|
||||||
:cover-image-field="view.card_cover_image_field"
|
:cover-image-field="view.card_cover_image_field"
|
||||||
|
@ -35,7 +35,6 @@
|
||||||
<ViewSearch
|
<ViewSearch
|
||||||
:view="view"
|
:view="view"
|
||||||
:fields="fields"
|
:fields="fields"
|
||||||
:primary="primary"
|
|
||||||
:store-prefix="storePrefix"
|
:store-prefix="storePrefix"
|
||||||
:always-hide-rows-not-matching-search="true"
|
:always-hide-rows-not-matching-search="true"
|
||||||
@refresh="$emit('refresh', $event)"
|
@refresh="$emit('refresh', $event)"
|
||||||
|
@ -71,10 +70,6 @@ export default {
|
||||||
type: Array,
|
type: Array,
|
||||||
required: true,
|
required: true,
|
||||||
},
|
},
|
||||||
primary: {
|
|
||||||
type: Object,
|
|
||||||
required: true,
|
|
||||||
},
|
|
||||||
readOnly: {
|
readOnly: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
required: true,
|
required: true,
|
||||||
|
@ -85,9 +80,6 @@ export default {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
allFields() {
|
|
||||||
return [this.primary].concat(this.fields)
|
|
||||||
},
|
|
||||||
...mapState({
|
...mapState({
|
||||||
tableLoading: (state) => state.table.loading,
|
tableLoading: (state) => state.table.loading,
|
||||||
}),
|
}),
|
||||||
|
|
|
@ -58,7 +58,7 @@
|
||||||
class="grid-view__divider-width"
|
class="grid-view__divider-width"
|
||||||
:style="{ left: leftWidth + 'px' }"
|
:style="{ left: leftWidth + 'px' }"
|
||||||
:grid="view"
|
:grid="view"
|
||||||
:field="primary"
|
:field="leftFields[0]"
|
||||||
:width="leftFieldsWidth"
|
:width="leftFieldsWidth"
|
||||||
:read-only="readOnly"
|
:read-only="readOnly"
|
||||||
:store-prefix="storePrefix"
|
:store-prefix="storePrefix"
|
||||||
|
@ -112,8 +112,7 @@
|
||||||
ref="rowDragging"
|
ref="rowDragging"
|
||||||
:table="table"
|
:table="table"
|
||||||
:view="view"
|
:view="view"
|
||||||
:primary="primary"
|
:fields="allVisibleFields"
|
||||||
:fields="visibleFields"
|
|
||||||
:store-prefix="storePrefix"
|
:store-prefix="storePrefix"
|
||||||
vertical="getVerticalScrollbarElement"
|
vertical="getVerticalScrollbarElement"
|
||||||
@scroll="scroll($event.pixelY, $event.pixelX)"
|
@scroll="scroll($event.pixelY, $event.pixelX)"
|
||||||
|
@ -184,8 +183,7 @@
|
||||||
ref="rowEditModal"
|
ref="rowEditModal"
|
||||||
:database="database"
|
:database="database"
|
||||||
:table="table"
|
:table="table"
|
||||||
:primary="primary"
|
:visible-fields="allVisibleFields"
|
||||||
:visible-fields="[primary].concat(visibleFields)"
|
|
||||||
:hidden-fields="hiddenFields"
|
:hidden-fields="hiddenFields"
|
||||||
:rows="allRows"
|
:rows="allRows"
|
||||||
:read-only="readOnly"
|
:read-only="readOnly"
|
||||||
|
@ -232,10 +230,6 @@ export default {
|
||||||
},
|
},
|
||||||
mixins: [viewHelpers, gridViewHelpers, viewDecoration],
|
mixins: [viewHelpers, gridViewHelpers, viewDecoration],
|
||||||
props: {
|
props: {
|
||||||
primary: {
|
|
||||||
type: Object,
|
|
||||||
required: true,
|
|
||||||
},
|
|
||||||
fields: {
|
fields: {
|
||||||
type: Array,
|
type: Array,
|
||||||
required: true,
|
required: true,
|
||||||
|
@ -266,12 +260,15 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
allVisibleFields() {
|
||||||
|
return this.leftFields.concat(this.visibleFields)
|
||||||
|
},
|
||||||
/**
|
/**
|
||||||
* Returns only the visible fields in the correct order.
|
* Returns only the visible fields in the correct order.
|
||||||
*/
|
*/
|
||||||
visibleFields() {
|
visibleFields() {
|
||||||
const fieldOptions = this.fieldOptions
|
const fieldOptions = this.fieldOptions
|
||||||
return this.fields
|
return this.rightFields
|
||||||
.filter(filterVisibleFieldsFunction(fieldOptions))
|
.filter(filterVisibleFieldsFunction(fieldOptions))
|
||||||
.sort(sortFieldsByOrderAndIdFunction(fieldOptions))
|
.sort(sortFieldsByOrderAndIdFunction(fieldOptions))
|
||||||
},
|
},
|
||||||
|
@ -280,12 +277,15 @@ export default {
|
||||||
*/
|
*/
|
||||||
hiddenFields() {
|
hiddenFields() {
|
||||||
const fieldOptions = this.fieldOptions
|
const fieldOptions = this.fieldOptions
|
||||||
return this.fields
|
return this.rightFields
|
||||||
.filter(filterHiddenFieldsFunction(fieldOptions))
|
.filter(filterHiddenFieldsFunction(fieldOptions))
|
||||||
.sort(sortFieldsByOrderAndIdFunction(fieldOptions))
|
.sort(sortFieldsByOrderAndIdFunction(fieldOptions))
|
||||||
},
|
},
|
||||||
leftFields() {
|
leftFields() {
|
||||||
return [this.primary]
|
return this.fields.filter((field) => field.primary)
|
||||||
|
},
|
||||||
|
rightFields() {
|
||||||
|
return this.fields.filter((field) => !field.primary)
|
||||||
},
|
},
|
||||||
leftFieldsWidth() {
|
leftFieldsWidth() {
|
||||||
return this.leftFields.reduce(
|
return this.leftFields.reduce(
|
||||||
|
@ -407,7 +407,6 @@ export default {
|
||||||
table: this.table,
|
table: this.table,
|
||||||
view: this.view,
|
view: this.view,
|
||||||
fields: this.fields,
|
fields: this.fields,
|
||||||
primary: this.primary,
|
|
||||||
row,
|
row,
|
||||||
field,
|
field,
|
||||||
value,
|
value,
|
||||||
|
@ -429,7 +428,6 @@ export default {
|
||||||
view: this.view,
|
view: this.view,
|
||||||
row,
|
row,
|
||||||
fields: this.fields,
|
fields: this.fields,
|
||||||
primary: this.primary,
|
|
||||||
overrides,
|
overrides,
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
@ -476,7 +474,6 @@ export default {
|
||||||
{
|
{
|
||||||
scrollTop: this.$refs.left.$refs.body.scrollTop,
|
scrollTop: this.$refs.left.$refs.body.scrollTop,
|
||||||
fields: this.fields,
|
fields: this.fields,
|
||||||
primary: this.primary,
|
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
|
@ -501,7 +498,6 @@ export default {
|
||||||
table: this.table,
|
table: this.table,
|
||||||
// We need a list of all fields including the primary one here.
|
// We need a list of all fields including the primary one here.
|
||||||
fields: this.fields,
|
fields: this.fields,
|
||||||
primary: this.primary,
|
|
||||||
values,
|
values,
|
||||||
before,
|
before,
|
||||||
}
|
}
|
||||||
|
@ -539,7 +535,6 @@ export default {
|
||||||
table: this.table,
|
table: this.table,
|
||||||
view: this.view,
|
view: this.view,
|
||||||
fields: this.fields,
|
fields: this.fields,
|
||||||
primary: this.primary,
|
|
||||||
row,
|
row,
|
||||||
getScrollTop,
|
getScrollTop,
|
||||||
}
|
}
|
||||||
|
@ -607,7 +602,6 @@ export default {
|
||||||
this.$store.dispatch(this.storePrefix + 'view/grid/refreshRow', {
|
this.$store.dispatch(this.storePrefix + 'view/grid/refreshRow', {
|
||||||
grid: this.view,
|
grid: this.view,
|
||||||
fields: this.fields,
|
fields: this.fields,
|
||||||
primary: this.primary,
|
|
||||||
row,
|
row,
|
||||||
getScrollTop: () => this.$refs.left.$refs.body.scrollTop,
|
getScrollTop: () => this.$refs.left.$refs.body.scrollTop,
|
||||||
})
|
})
|
||||||
|
@ -698,7 +692,6 @@ export default {
|
||||||
{
|
{
|
||||||
grid: this.view,
|
grid: this.view,
|
||||||
fields: this.fields,
|
fields: this.fields,
|
||||||
primary: this.primary,
|
|
||||||
row,
|
row,
|
||||||
field,
|
field,
|
||||||
getScrollTop,
|
getScrollTop,
|
||||||
|
@ -713,7 +706,7 @@ export default {
|
||||||
*/
|
*/
|
||||||
selectNextCell({ row, field, direction = 'next' }) {
|
selectNextCell({ row, field, direction = 'next' }) {
|
||||||
const fields = this.visibleFields
|
const fields = this.visibleFields
|
||||||
const primary = this.primary
|
const primary = this.leftFields[0]
|
||||||
let nextFieldId = -1
|
let nextFieldId = -1
|
||||||
let nextRowId = -1
|
let nextRowId = -1
|
||||||
|
|
||||||
|
@ -868,7 +861,7 @@ export default {
|
||||||
this.$store.dispatch('notification/setCopying', true)
|
this.$store.dispatch('notification/setCopying', true)
|
||||||
const output = await this.$store.dispatch(
|
const output = await this.$store.dispatch(
|
||||||
this.storePrefix + 'view/grid/exportMultiSelect',
|
this.storePrefix + 'view/grid/exportMultiSelect',
|
||||||
this.leftFields.concat(this.visibleFields)
|
this.allVisibleFields
|
||||||
)
|
)
|
||||||
// If the output is undefined, it means that there is no multiple selection.
|
// If the output is undefined, it means that there is no multiple selection.
|
||||||
if (output !== undefined) {
|
if (output !== undefined) {
|
||||||
|
@ -933,8 +926,7 @@ export default {
|
||||||
{
|
{
|
||||||
table: this.table,
|
table: this.table,
|
||||||
view: this.view,
|
view: this.view,
|
||||||
primary: this.primary,
|
fields: this.allVisibleFields,
|
||||||
fields: this.leftFields.concat(this.visibleFields),
|
|
||||||
getScrollTop: () => this.$refs.left.$refs.body.scrollTop,
|
getScrollTop: () => this.$refs.left.$refs.body.scrollTop,
|
||||||
data,
|
data,
|
||||||
rowIndex,
|
rowIndex,
|
||||||
|
@ -961,8 +953,7 @@ export default {
|
||||||
{
|
{
|
||||||
table: this.table,
|
table: this.table,
|
||||||
view: this.view,
|
view: this.view,
|
||||||
primary: this.primary,
|
fields: this.allVisibleFields,
|
||||||
fields: this.leftFields.concat(this.visibleFields),
|
|
||||||
getScrollTop: () => this.$refs.left.$refs.body.scrollTop,
|
getScrollTop: () => this.$refs.left.$refs.body.scrollTop,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
@ -986,8 +977,7 @@ export default {
|
||||||
{
|
{
|
||||||
table: this.table,
|
table: this.table,
|
||||||
view: this.view,
|
view: this.view,
|
||||||
primary: this.primary,
|
fields: this.allVisibleFields,
|
||||||
fields: this.leftFields.concat(this.visibleFields),
|
|
||||||
getScrollTop: () => this.$refs.left.$refs.body.scrollTop,
|
getScrollTop: () => this.$refs.left.$refs.body.scrollTop,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
<li class="header__filter-item">
|
<li class="header__filter-item">
|
||||||
<GridViewHide
|
<GridViewHide
|
||||||
:view="view"
|
:view="view"
|
||||||
:fields="fields"
|
:fields="fieldsAllowedToBeHidden"
|
||||||
:read-only="readOnly"
|
:read-only="readOnly"
|
||||||
:store-prefix="storePrefix"
|
:store-prefix="storePrefix"
|
||||||
></GridViewHide>
|
></GridViewHide>
|
||||||
|
@ -12,7 +12,6 @@
|
||||||
<ViewSearch
|
<ViewSearch
|
||||||
:view="view"
|
:view="view"
|
||||||
:fields="fields"
|
:fields="fields"
|
||||||
:primary="primary"
|
|
||||||
:store-prefix="storePrefix"
|
:store-prefix="storePrefix"
|
||||||
@refresh="$emit('refresh', $event)"
|
@refresh="$emit('refresh', $event)"
|
||||||
></ViewSearch>
|
></ViewSearch>
|
||||||
|
@ -38,10 +37,6 @@ export default {
|
||||||
type: Array,
|
type: Array,
|
||||||
required: true,
|
required: true,
|
||||||
},
|
},
|
||||||
primary: {
|
|
||||||
type: Object,
|
|
||||||
required: true,
|
|
||||||
},
|
|
||||||
readOnly: {
|
readOnly: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
required: true,
|
required: true,
|
||||||
|
@ -55,6 +50,9 @@ export default {
|
||||||
...mapState({
|
...mapState({
|
||||||
tableLoading: (state) => state.table.loading,
|
tableLoading: (state) => state.table.loading,
|
||||||
}),
|
}),
|
||||||
|
fieldsAllowedToBeHidden() {
|
||||||
|
return this.fields.filter((field) => !field.primary)
|
||||||
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -29,10 +29,6 @@ export default {
|
||||||
type: Object,
|
type: Object,
|
||||||
required: true,
|
required: true,
|
||||||
},
|
},
|
||||||
primary: {
|
|
||||||
type: Object,
|
|
||||||
required: true,
|
|
||||||
},
|
|
||||||
fields: {
|
fields: {
|
||||||
type: Array,
|
type: Array,
|
||||||
required: true,
|
required: true,
|
||||||
|
@ -66,9 +62,8 @@ export default {
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
width() {
|
width() {
|
||||||
const allFields = [this.primary].concat(this.fields)
|
|
||||||
return (
|
return (
|
||||||
allFields.reduce(
|
this.fields.reduce(
|
||||||
(value, field) => this.getFieldWidth(field.id) + value,
|
(value, field) => this.getFieldWidth(field.id) + value,
|
||||||
0
|
0
|
||||||
) + this.gridViewRowDetailsWidth
|
) + this.gridViewRowDetailsWidth
|
||||||
|
@ -245,7 +240,6 @@ export default {
|
||||||
table: this.table,
|
table: this.table,
|
||||||
grid: this.view,
|
grid: this.view,
|
||||||
fields: this.fields,
|
fields: this.fields,
|
||||||
primary: this.primary,
|
|
||||||
getScrollTop,
|
getScrollTop,
|
||||||
row: this.row,
|
row: this.row,
|
||||||
before: this.targetRow,
|
before: this.targetRow,
|
||||||
|
|
|
@ -331,7 +331,7 @@ export default {
|
||||||
return webhookEvent.getExamplePayload(this.table, rowExample)
|
return webhookEvent.getExamplePayload(this.table, rowExample)
|
||||||
},
|
},
|
||||||
...mapGetters({
|
...mapGetters({
|
||||||
fields: 'field/getAllWithPrimary',
|
fields: 'field/getAll',
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
|
|
|
@ -88,7 +88,6 @@ export default {
|
||||||
`${this.getDragAndDropStoreName(this)}/cancelRowDrag`,
|
`${this.getDragAndDropStoreName(this)}/cancelRowDrag`,
|
||||||
{
|
{
|
||||||
view: this.view,
|
view: this.view,
|
||||||
primary: this.primary,
|
|
||||||
fields: this.fields,
|
fields: this.fields,
|
||||||
row: this.dragAndDropDraggingRow,
|
row: this.dragAndDropDraggingRow,
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,15 +19,8 @@ export default {
|
||||||
type: Array,
|
type: Array,
|
||||||
required: true,
|
required: true,
|
||||||
},
|
},
|
||||||
primary: {
|
|
||||||
type: Object,
|
|
||||||
required: true,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
allTableFields() {
|
|
||||||
return [this.primary, ...this.fields]
|
|
||||||
},
|
|
||||||
activeDecorations() {
|
activeDecorations() {
|
||||||
return this.view.decorations
|
return this.view.decorations
|
||||||
.map((decoration) => {
|
.map((decoration) => {
|
||||||
|
@ -51,7 +44,7 @@ export default {
|
||||||
return {
|
return {
|
||||||
value: deco.valueProviderType.getValue({
|
value: deco.valueProviderType.getValue({
|
||||||
row,
|
row,
|
||||||
fields: this.allTableFields,
|
fields: this.fields,
|
||||||
options: decoration.value_provider_conf,
|
options: decoration.value_provider_conf,
|
||||||
}),
|
}),
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,10 +14,6 @@ export default {
|
||||||
type: Object,
|
type: Object,
|
||||||
required: true,
|
required: true,
|
||||||
},
|
},
|
||||||
primary: {
|
|
||||||
type: Object,
|
|
||||||
required: true,
|
|
||||||
},
|
|
||||||
fields: {
|
fields: {
|
||||||
type: Array,
|
type: Array,
|
||||||
required: true,
|
required: true,
|
||||||
|
@ -33,9 +29,10 @@ export default {
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
field() {
|
field() {
|
||||||
return this.primary.id === this.filter.field
|
return this.fields.find((f) => f.id === this.filter.field)
|
||||||
? this.primary
|
},
|
||||||
: this.fields.find((f) => f.id === this.filter.field)
|
primary() {
|
||||||
|
return this.fields.find((f) => f.primary)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,8 +5,7 @@
|
||||||
<Table
|
<Table
|
||||||
:database="database"
|
:database="database"
|
||||||
:table="table"
|
:table="table"
|
||||||
:fields="fields || startingFields"
|
:fields="fields"
|
||||||
:primary="primary || startingPrimary"
|
|
||||||
:view="view"
|
:view="view"
|
||||||
:read-only="true"
|
:read-only="true"
|
||||||
:table-loading="false"
|
:table-loading="false"
|
||||||
|
@ -63,7 +62,7 @@ export default {
|
||||||
const table = database.tables[0]
|
const table = database.tables[0]
|
||||||
await store.dispatch('table/forceSelect', { database, table })
|
await store.dispatch('table/forceSelect', { database, table })
|
||||||
|
|
||||||
const { primary, fields } = await store.dispatch('field/forceSetFields', {
|
await store.dispatch('field/forceSetFields', {
|
||||||
fields: data.fields,
|
fields: data.fields,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -79,13 +78,11 @@ export default {
|
||||||
// It might be possible that the view also has some stores that need to be
|
// It might be possible that the view also has some stores that need to be
|
||||||
// filled with initial data, so we're going to call the fetch function here.
|
// filled with initial data, so we're going to call the fetch function here.
|
||||||
const type = app.$registry.get('view', view.type)
|
const type = app.$registry.get('view', view.type)
|
||||||
await type.fetch({ store }, view, fields, primary, 'page/')
|
await type.fetch({ store }, view, data.fields, 'page/')
|
||||||
return {
|
return {
|
||||||
database,
|
database,
|
||||||
table,
|
table,
|
||||||
view,
|
view,
|
||||||
startingFields: fields,
|
|
||||||
startingPrimary: primary,
|
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
const statusCode = e.response?.status
|
const statusCode = e.response?.status
|
||||||
|
@ -109,7 +106,6 @@ export default {
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
...mapGetters({
|
...mapGetters({
|
||||||
primary: 'field/getPrimary',
|
|
||||||
fields: 'field/getAll',
|
fields: 'field/getAll',
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
:database="database"
|
:database="database"
|
||||||
:table="table"
|
:table="table"
|
||||||
:fields="fields"
|
:fields="fields"
|
||||||
:primary="primary"
|
|
||||||
:views="views"
|
:views="views"
|
||||||
:view="view"
|
:view="view"
|
||||||
:table-loading="tableLoading"
|
:table-loading="tableLoading"
|
||||||
|
@ -75,7 +74,6 @@ export default {
|
||||||
// After selecting the table the fields become available which need to be added to
|
// After selecting the table the fields become available which need to be added to
|
||||||
// the data.
|
// the data.
|
||||||
data.fields = store.getters['field/getAll']
|
data.fields = store.getters['field/getAll']
|
||||||
data.primary = store.getters['field/getPrimary']
|
|
||||||
data.view = undefined
|
data.view = undefined
|
||||||
|
|
||||||
// Because we do not have a dashboard for the table yet we're going to redirect to
|
// Because we do not have a dashboard for the table yet we're going to redirect to
|
||||||
|
@ -101,7 +99,7 @@ export default {
|
||||||
return error({ statusCode: 400, message: type.getDeactivatedText() })
|
return error({ statusCode: 400, message: type.getDeactivatedText() })
|
||||||
}
|
}
|
||||||
|
|
||||||
await type.fetch({ store }, view, data.fields, data.primary, 'page/')
|
await type.fetch({ store }, view, data.fields, 'page/')
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// In case of a network error we want to fail hard.
|
// In case of a network error we want to fail hard.
|
||||||
if (e.response === undefined && !(e instanceof StoreItemLookupError)) {
|
if (e.response === undefined && !(e instanceof StoreItemLookupError)) {
|
||||||
|
|
|
@ -163,7 +163,6 @@ export const registerRealtimeEvents = (realtime) => {
|
||||||
context,
|
context,
|
||||||
data.table_id,
|
data.table_id,
|
||||||
store.getters['field/getAll'],
|
store.getters['field/getAll'],
|
||||||
store.getters['field/getPrimary'],
|
|
||||||
data.rows[i],
|
data.rows[i],
|
||||||
data.metadata,
|
data.metadata,
|
||||||
'page/'
|
'page/'
|
||||||
|
@ -183,7 +182,6 @@ export const registerRealtimeEvents = (realtime) => {
|
||||||
context,
|
context,
|
||||||
data.table_id,
|
data.table_id,
|
||||||
store.getters['field/getAll'],
|
store.getters['field/getAll'],
|
||||||
store.getters['field/getPrimary'],
|
|
||||||
rowBeforeUpdate,
|
rowBeforeUpdate,
|
||||||
row,
|
row,
|
||||||
data.metadata,
|
data.metadata,
|
||||||
|
@ -205,7 +203,6 @@ export const registerRealtimeEvents = (realtime) => {
|
||||||
context,
|
context,
|
||||||
data.table_id,
|
data.table_id,
|
||||||
store.getters['field/getAll'],
|
store.getters['field/getAll'],
|
||||||
store.getters['field/getPrimary'],
|
|
||||||
row,
|
row,
|
||||||
'page/'
|
'page/'
|
||||||
)
|
)
|
||||||
|
|
|
@ -15,7 +15,6 @@ export const state = () => ({
|
||||||
types: {},
|
types: {},
|
||||||
loading: false,
|
loading: false,
|
||||||
loaded: false,
|
loaded: false,
|
||||||
primary: null,
|
|
||||||
items: [],
|
items: [],
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -35,9 +34,6 @@ export const mutations = {
|
||||||
SET_LOADED(state, value) {
|
SET_LOADED(state, value) {
|
||||||
state.loaded = value
|
state.loaded = value
|
||||||
},
|
},
|
||||||
SET_PRIMARY(state, item) {
|
|
||||||
state.primary = Object.assign(state.primary || {}, item)
|
|
||||||
},
|
|
||||||
ADD_ITEM(state, item) {
|
ADD_ITEM(state, item) {
|
||||||
state.items.push(item)
|
state.items.push(item)
|
||||||
},
|
},
|
||||||
|
@ -95,15 +91,11 @@ export const actions = {
|
||||||
populateField(fields[index], this.$registry)
|
populateField(fields[index], this.$registry)
|
||||||
})
|
})
|
||||||
|
|
||||||
const primaryIndex = fields.findIndex((item) => item.primary === true)
|
|
||||||
const primary =
|
|
||||||
primaryIndex !== -1 ? fields.splice(primaryIndex, 1)[0] : null
|
|
||||||
commit('SET_PRIMARY', primary)
|
|
||||||
commit('SET_ITEMS', fields)
|
commit('SET_ITEMS', fields)
|
||||||
commit('SET_LOADING', false)
|
commit('SET_LOADING', false)
|
||||||
commit('SET_LOADED', true)
|
commit('SET_LOADED', true)
|
||||||
|
|
||||||
return { primary, fields }
|
return { fields }
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* Creates a new field with the provided type for the given table.
|
* Creates a new field with the provided type for the given table.
|
||||||
|
@ -184,11 +176,7 @@ export const actions = {
|
||||||
const { commit, dispatch } = context
|
const { commit, dispatch } = context
|
||||||
const fieldType = this.$registry.get('field', values.type)
|
const fieldType = this.$registry.get('field', values.type)
|
||||||
const data = populateField(values, this.$registry)
|
const data = populateField(values, this.$registry)
|
||||||
if (data.primary) {
|
commit('ADD_ITEM', data)
|
||||||
commit('SET_PRIMARY', data)
|
|
||||||
} else {
|
|
||||||
commit('ADD_ITEM', data)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Call the field created event on all the registered views because they might
|
// Call the field created event on all the registered views because they might
|
||||||
// need to change things in loaded data. For example the grid field will add the
|
// need to change things in loaded data. For example the grid field will add the
|
||||||
|
@ -242,11 +230,8 @@ export const actions = {
|
||||||
const fieldType = this.$registry.get('field', data.type)
|
const fieldType = this.$registry.get('field', data.type)
|
||||||
data = populateField(data, this.$registry)
|
data = populateField(data, this.$registry)
|
||||||
|
|
||||||
if (field.primary) {
|
commit('UPDATE_ITEM', { id: field.id, values: data })
|
||||||
commit('SET_PRIMARY', data)
|
commit('UPDATE_ITEM', { id: field.id, values: data })
|
||||||
} else {
|
|
||||||
commit('UPDATE_ITEM', { id: field.id, values: data })
|
|
||||||
}
|
|
||||||
|
|
||||||
// The view might need to do some cleanup regarding the filters and sortings if the
|
// The view might need to do some cleanup regarding the filters and sortings if the
|
||||||
// type has changed.
|
// type has changed.
|
||||||
|
@ -339,22 +324,11 @@ export const getters = {
|
||||||
return state.loaded
|
return state.loaded
|
||||||
},
|
},
|
||||||
get: (state) => (id) => {
|
get: (state) => (id) => {
|
||||||
const primary = state.primary.id === id ? state.primary : undefined
|
return state.items.find((item) => item.id === id)
|
||||||
return state.items.find((item) => item.id === id) || primary
|
|
||||||
},
|
|
||||||
getPrimary: (state) => {
|
|
||||||
return state.primary
|
|
||||||
},
|
},
|
||||||
getAll(state) {
|
getAll(state) {
|
||||||
return state.items
|
return state.items
|
||||||
},
|
},
|
||||||
getAllWithPrimary(state) {
|
|
||||||
if (state.primary !== null) {
|
|
||||||
return [state.primary, ...state.items]
|
|
||||||
} else {
|
|
||||||
return state.items
|
|
||||||
}
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
|
|
@ -254,7 +254,7 @@ export default ({ service, customPopulateRow }) => {
|
||||||
*/
|
*/
|
||||||
async fetchInitialRows(
|
async fetchInitialRows(
|
||||||
context,
|
context,
|
||||||
{ viewId, fields, primary, initialRowArguments = {} }
|
{ viewId, fields, initialRowArguments = {} }
|
||||||
) {
|
) {
|
||||||
const { commit, getters } = context
|
const { commit, getters } = context
|
||||||
commit('SET_VIEW_ID', viewId)
|
commit('SET_VIEW_ID', viewId)
|
||||||
|
@ -366,7 +366,7 @@ export default ({ service, customPopulateRow }) => {
|
||||||
*/
|
*/
|
||||||
async refresh(
|
async refresh(
|
||||||
{ dispatch, commit, getters },
|
{ dispatch, commit, getters },
|
||||||
{ fields, primary, includeFieldOptions = false }
|
{ fields, includeFieldOptions = false }
|
||||||
) {
|
) {
|
||||||
// If another refresh or fetch request is currently running, we need to cancel
|
// If another refresh or fetch request is currently running, we need to cancel
|
||||||
// it because the response is most likely going to be outdated and we don't
|
// it because the response is most likely going to be outdated and we don't
|
||||||
|
@ -458,7 +458,7 @@ export default ({ service, customPopulateRow }) => {
|
||||||
/**
|
/**
|
||||||
* Check if the provided row matches the provided view filters.
|
* Check if the provided row matches the provided view filters.
|
||||||
*/
|
*/
|
||||||
rowMatchesFilters(context, { view, fields, primary, row, overrides = {} }) {
|
rowMatchesFilters(context, { view, fields, row, overrides = {} }) {
|
||||||
const values = JSON.parse(JSON.stringify(row))
|
const values = JSON.parse(JSON.stringify(row))
|
||||||
Object.assign(values, overrides)
|
Object.assign(values, overrides)
|
||||||
|
|
||||||
|
@ -469,7 +469,7 @@ export default ({ service, customPopulateRow }) => {
|
||||||
this.$registry,
|
this.$registry,
|
||||||
view.filter_type,
|
view.filter_type,
|
||||||
view.filters,
|
view.filters,
|
||||||
primary === null ? fields : [primary, ...fields],
|
fields,
|
||||||
values
|
values
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
|
@ -478,12 +478,11 @@ export default ({ service, customPopulateRow }) => {
|
||||||
* store. Because some rows haven't been fetched from the backend, we need to
|
* store. Because some rows haven't been fetched from the backend, we need to
|
||||||
* figure out which `null` object could have been the row in the store.
|
* figure out which `null` object could have been the row in the store.
|
||||||
*/
|
*/
|
||||||
findIndexOfNotExistingRow({ getters }, { view, fields, primary, row }) {
|
findIndexOfNotExistingRow({ getters }, { view, fields, row }) {
|
||||||
const sortFunction = getRowSortFunction(
|
const sortFunction = getRowSortFunction(
|
||||||
this.$registry,
|
this.$registry,
|
||||||
view.sortings,
|
view.sortings,
|
||||||
fields,
|
fields
|
||||||
primary
|
|
||||||
)
|
)
|
||||||
const allRows = getters.getRows
|
const allRows = getters.getRows
|
||||||
let index = allRows.findIndex((existingRow) => {
|
let index = allRows.findIndex((existingRow) => {
|
||||||
|
@ -516,15 +515,11 @@ export default ({ service, customPopulateRow }) => {
|
||||||
* hasn't been fetched yet, it will then point to the `null` object representing
|
* hasn't been fetched yet, it will then point to the `null` object representing
|
||||||
* the row.
|
* the row.
|
||||||
*/
|
*/
|
||||||
findIndexOfExistingRow(
|
findIndexOfExistingRow({ dispatch, getters }, { view, fields, row }) {
|
||||||
{ dispatch, getters },
|
|
||||||
{ view, fields, primary, row }
|
|
||||||
) {
|
|
||||||
const sortFunction = getRowSortFunction(
|
const sortFunction = getRowSortFunction(
|
||||||
this.$registry,
|
this.$registry,
|
||||||
view.sortings,
|
view.sortings,
|
||||||
fields,
|
fields
|
||||||
primary
|
|
||||||
)
|
)
|
||||||
const allRows = getters.getRows
|
const allRows = getters.getRows
|
||||||
let index = allRows.findIndex((existingRow) => {
|
let index = allRows.findIndex((existingRow) => {
|
||||||
|
@ -559,12 +554,11 @@ export default ({ service, customPopulateRow }) => {
|
||||||
*/
|
*/
|
||||||
async createNewRow(
|
async createNewRow(
|
||||||
{ dispatch, commit, getters },
|
{ dispatch, commit, getters },
|
||||||
{ view, table, fields, primary, values }
|
{ view, table, fields, values }
|
||||||
) {
|
) {
|
||||||
// First prepare an object that we can send to the backend.
|
// First prepare an object that we can send to the backend.
|
||||||
const allFields = [primary].concat(fields)
|
|
||||||
const preparedValues = {}
|
const preparedValues = {}
|
||||||
allFields.forEach((field) => {
|
fields.forEach((field) => {
|
||||||
const name = `field_${field.id}`
|
const name = `field_${field.id}`
|
||||||
const fieldType = this.$registry.get('field', field._.type.type)
|
const fieldType = this.$registry.get('field', field._.type.type)
|
||||||
|
|
||||||
|
@ -590,7 +584,6 @@ export default ({ service, customPopulateRow }) => {
|
||||||
return await dispatch('afterNewRowCreated', {
|
return await dispatch('afterNewRowCreated', {
|
||||||
view,
|
view,
|
||||||
fields,
|
fields,
|
||||||
primary,
|
|
||||||
values: data,
|
values: data,
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
@ -609,7 +602,7 @@ export default ({ service, customPopulateRow }) => {
|
||||||
*/
|
*/
|
||||||
async afterNewRowCreated(
|
async afterNewRowCreated(
|
||||||
{ dispatch, getters, commit },
|
{ dispatch, getters, commit },
|
||||||
{ view, fields, primary, values }
|
{ view, fields, values }
|
||||||
) {
|
) {
|
||||||
let row = clone(values)
|
let row = clone(values)
|
||||||
populateRow(row)
|
populateRow(row)
|
||||||
|
@ -617,13 +610,11 @@ export default ({ service, customPopulateRow }) => {
|
||||||
const rowMatchesFilters = await dispatch('rowMatchesFilters', {
|
const rowMatchesFilters = await dispatch('rowMatchesFilters', {
|
||||||
view,
|
view,
|
||||||
fields,
|
fields,
|
||||||
primary,
|
|
||||||
row,
|
row,
|
||||||
})
|
})
|
||||||
await dispatch('updateSearchMatchesForRow', {
|
await dispatch('updateSearchMatchesForRow', {
|
||||||
view,
|
view,
|
||||||
fields,
|
fields,
|
||||||
primary,
|
|
||||||
row,
|
row,
|
||||||
})
|
})
|
||||||
if (!rowMatchesFilters || !row._.matchSearch) {
|
if (!rowMatchesFilters || !row._.matchSearch) {
|
||||||
|
@ -633,7 +624,6 @@ export default ({ service, customPopulateRow }) => {
|
||||||
const { index, isCertain } = await dispatch('findIndexOfNotExistingRow', {
|
const { index, isCertain } = await dispatch('findIndexOfNotExistingRow', {
|
||||||
view,
|
view,
|
||||||
fields,
|
fields,
|
||||||
primary,
|
|
||||||
row,
|
row,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -651,10 +641,9 @@ export default ({ service, customPopulateRow }) => {
|
||||||
*/
|
*/
|
||||||
async updateRowValue(
|
async updateRowValue(
|
||||||
{ commit, dispatch },
|
{ commit, dispatch },
|
||||||
{ table, view, row, field, fields, primary, value, oldValue }
|
{ table, view, row, field, fields, value, oldValue }
|
||||||
) {
|
) {
|
||||||
const fieldType = this.$registry.get('field', field._.type.type)
|
const fieldType = this.$registry.get('field', field._.type.type)
|
||||||
const allFields = [primary].concat(fields)
|
|
||||||
const newValues = {}
|
const newValues = {}
|
||||||
const newValuesForUpdate = {}
|
const newValuesForUpdate = {}
|
||||||
const oldValues = {}
|
const oldValues = {}
|
||||||
|
@ -666,7 +655,7 @@ export default ({ service, customPopulateRow }) => {
|
||||||
)
|
)
|
||||||
oldValues[fieldName] = oldValue
|
oldValues[fieldName] = oldValue
|
||||||
|
|
||||||
allFields.forEach((fieldToCall) => {
|
fields.forEach((fieldToCall) => {
|
||||||
const fieldType = this.$registry.get('field', fieldToCall._.type.type)
|
const fieldType = this.$registry.get('field', fieldToCall._.type.type)
|
||||||
const fieldToCallName = `field_${fieldToCall.id}`
|
const fieldToCallName = `field_${fieldToCall.id}`
|
||||||
const currentFieldValue = row[fieldToCallName]
|
const currentFieldValue = row[fieldToCallName]
|
||||||
|
@ -685,7 +674,6 @@ export default ({ service, customPopulateRow }) => {
|
||||||
await dispatch('afterExistingRowUpdated', {
|
await dispatch('afterExistingRowUpdated', {
|
||||||
view,
|
view,
|
||||||
fields,
|
fields,
|
||||||
primary,
|
|
||||||
row,
|
row,
|
||||||
values: newValues,
|
values: newValues,
|
||||||
})
|
})
|
||||||
|
@ -698,10 +686,9 @@ export default ({ service, customPopulateRow }) => {
|
||||||
)
|
)
|
||||||
commit('UPDATE_ROW', { row, values: data })
|
commit('UPDATE_ROW', { row, values: data })
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
dispatch('updatedExistingRow', {
|
dispatch('afterExistingRowUpdated', {
|
||||||
view,
|
view,
|
||||||
fields,
|
fields,
|
||||||
primary,
|
|
||||||
row,
|
row,
|
||||||
values: oldValues,
|
values: oldValues,
|
||||||
})
|
})
|
||||||
|
@ -722,7 +709,7 @@ export default ({ service, customPopulateRow }) => {
|
||||||
*/
|
*/
|
||||||
async afterExistingRowUpdated(
|
async afterExistingRowUpdated(
|
||||||
{ dispatch, commit },
|
{ dispatch, commit },
|
||||||
{ view, fields, primary, row, values }
|
{ view, fields, row, values }
|
||||||
) {
|
) {
|
||||||
const oldRow = clone(row)
|
const oldRow = clone(row)
|
||||||
let newRow = Object.assign(clone(row), values)
|
let newRow = Object.assign(clone(row), values)
|
||||||
|
@ -732,25 +719,21 @@ export default ({ service, customPopulateRow }) => {
|
||||||
const oldMatchesFilters = await dispatch('rowMatchesFilters', {
|
const oldMatchesFilters = await dispatch('rowMatchesFilters', {
|
||||||
view,
|
view,
|
||||||
fields,
|
fields,
|
||||||
primary,
|
|
||||||
row: oldRow,
|
row: oldRow,
|
||||||
})
|
})
|
||||||
const newMatchesFilters = await dispatch('rowMatchesFilters', {
|
const newMatchesFilters = await dispatch('rowMatchesFilters', {
|
||||||
view,
|
view,
|
||||||
fields,
|
fields,
|
||||||
primary,
|
|
||||||
row: newRow,
|
row: newRow,
|
||||||
})
|
})
|
||||||
await dispatch('updateSearchMatchesForRow', {
|
await dispatch('updateSearchMatchesForRow', {
|
||||||
view,
|
view,
|
||||||
fields,
|
fields,
|
||||||
primary,
|
|
||||||
row: oldRow,
|
row: oldRow,
|
||||||
})
|
})
|
||||||
await dispatch('updateSearchMatchesForRow', {
|
await dispatch('updateSearchMatchesForRow', {
|
||||||
view,
|
view,
|
||||||
fields,
|
fields,
|
||||||
primary,
|
|
||||||
row: newRow,
|
row: newRow,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -763,7 +746,6 @@ export default ({ service, customPopulateRow }) => {
|
||||||
await dispatch('afterExistingRowDeleted', {
|
await dispatch('afterExistingRowDeleted', {
|
||||||
view,
|
view,
|
||||||
fields,
|
fields,
|
||||||
primary,
|
|
||||||
row,
|
row,
|
||||||
})
|
})
|
||||||
} else if (!oldRowMatches && newRowMatches) {
|
} else if (!oldRowMatches && newRowMatches) {
|
||||||
|
@ -772,7 +754,6 @@ export default ({ service, customPopulateRow }) => {
|
||||||
await dispatch('afterNewRowCreated', {
|
await dispatch('afterNewRowCreated', {
|
||||||
view,
|
view,
|
||||||
fields,
|
fields,
|
||||||
primary,
|
|
||||||
values: newRow,
|
values: newRow,
|
||||||
})
|
})
|
||||||
} else if (oldRowMatches && newRowMatches) {
|
} else if (oldRowMatches && newRowMatches) {
|
||||||
|
@ -782,14 +763,12 @@ export default ({ service, customPopulateRow }) => {
|
||||||
{
|
{
|
||||||
view,
|
view,
|
||||||
fields,
|
fields,
|
||||||
primary,
|
|
||||||
row: oldRow,
|
row: oldRow,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
const findNewRow = await dispatch('findIndexOfNotExistingRow', {
|
const findNewRow = await dispatch('findIndexOfNotExistingRow', {
|
||||||
view,
|
view,
|
||||||
fields,
|
fields,
|
||||||
primary,
|
|
||||||
row: newRow,
|
row: newRow,
|
||||||
})
|
})
|
||||||
let { index: newIndex } = findNewRow
|
let { index: newIndex } = findNewRow
|
||||||
|
@ -831,23 +810,18 @@ export default ({ service, customPopulateRow }) => {
|
||||||
* removed from is. Based on the provided values of the row we can figure out if
|
* removed from is. Based on the provided values of the row we can figure out if
|
||||||
* it was in the store and we can figure out what index it has.
|
* it was in the store and we can figure out what index it has.
|
||||||
*/
|
*/
|
||||||
async afterExistingRowDeleted(
|
async afterExistingRowDeleted({ dispatch, commit }, { view, fields, row }) {
|
||||||
{ dispatch, commit },
|
|
||||||
{ view, fields, primary, row }
|
|
||||||
) {
|
|
||||||
row = clone(row)
|
row = clone(row)
|
||||||
populateRow(row)
|
populateRow(row)
|
||||||
|
|
||||||
const rowMatchesFilters = await dispatch('rowMatchesFilters', {
|
const rowMatchesFilters = await dispatch('rowMatchesFilters', {
|
||||||
view,
|
view,
|
||||||
fields,
|
fields,
|
||||||
primary,
|
|
||||||
row,
|
row,
|
||||||
})
|
})
|
||||||
await dispatch('updateSearchMatchesForRow', {
|
await dispatch('updateSearchMatchesForRow', {
|
||||||
view,
|
view,
|
||||||
fields,
|
fields,
|
||||||
primary,
|
|
||||||
row,
|
row,
|
||||||
})
|
})
|
||||||
if (!rowMatchesFilters || !row._.matchSearch) {
|
if (!rowMatchesFilters || !row._.matchSearch) {
|
||||||
|
@ -857,7 +831,6 @@ export default ({ service, customPopulateRow }) => {
|
||||||
const { index } = await dispatch('findIndexOfExistingRow', {
|
const { index } = await dispatch('findIndexOfExistingRow', {
|
||||||
view,
|
view,
|
||||||
fields,
|
fields,
|
||||||
primary,
|
|
||||||
row,
|
row,
|
||||||
})
|
})
|
||||||
commit('DELETE_ROW_AT_INDEX', { index })
|
commit('DELETE_ROW_AT_INDEX', { index })
|
||||||
|
@ -876,10 +849,7 @@ export default ({ service, customPopulateRow }) => {
|
||||||
* need to updated and will make a call to the backend. If something goes wrong,
|
* need to updated and will make a call to the backend. If something goes wrong,
|
||||||
* the row is moved back to the position.
|
* the row is moved back to the position.
|
||||||
*/
|
*/
|
||||||
async stopRowDrag(
|
async stopRowDrag({ dispatch, commit, getters }, { table, view, fields }) {
|
||||||
{ dispatch, commit, getters },
|
|
||||||
{ table, view, fields, primary }
|
|
||||||
) {
|
|
||||||
const row = getters.getDraggingRow
|
const row = getters.getDraggingRow
|
||||||
|
|
||||||
if (row === null) {
|
if (row === null) {
|
||||||
|
@ -902,7 +872,7 @@ export default ({ service, customPopulateRow }) => {
|
||||||
)
|
)
|
||||||
commit('UPDATE_ROW', { row, values: data })
|
commit('UPDATE_ROW', { row, values: data })
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
dispatch('cancelRowDrag', { view, fields, primary, row, stop: false })
|
dispatch('cancelRowDrag', { view, fields, row, stop: false })
|
||||||
throw error
|
throw error
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -913,7 +883,7 @@ export default ({ service, customPopulateRow }) => {
|
||||||
*/
|
*/
|
||||||
cancelRowDrag(
|
cancelRowDrag(
|
||||||
{ dispatch, getters, commit },
|
{ dispatch, getters, commit },
|
||||||
{ view, fields, primary, row, stop = true }
|
{ view, fields, row, stop = true }
|
||||||
) {
|
) {
|
||||||
if (stop) {
|
if (stop) {
|
||||||
const rows = getters.getRows
|
const rows = getters.getRows
|
||||||
|
@ -924,7 +894,6 @@ export default ({ service, customPopulateRow }) => {
|
||||||
dispatch('afterExistingRowUpdated', {
|
dispatch('afterExistingRowUpdated', {
|
||||||
view,
|
view,
|
||||||
fields,
|
fields,
|
||||||
primary,
|
|
||||||
row,
|
row,
|
||||||
values: row,
|
values: row,
|
||||||
})
|
})
|
||||||
|
@ -958,7 +927,6 @@ export default ({ service, customPopulateRow }) => {
|
||||||
{ commit, dispatch, getters, state },
|
{ commit, dispatch, getters, state },
|
||||||
{
|
{
|
||||||
fields,
|
fields,
|
||||||
primary = null,
|
|
||||||
activeSearchTerm = state.activeSearchTerm,
|
activeSearchTerm = state.activeSearchTerm,
|
||||||
refreshMatchesOnClient = true,
|
refreshMatchesOnClient = true,
|
||||||
}
|
}
|
||||||
|
@ -969,7 +937,6 @@ export default ({ service, customPopulateRow }) => {
|
||||||
dispatch('updateSearchMatchesForRow', {
|
dispatch('updateSearchMatchesForRow', {
|
||||||
row,
|
row,
|
||||||
fields,
|
fields,
|
||||||
primary,
|
|
||||||
forced: true,
|
forced: true,
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
|
@ -982,7 +949,7 @@ export default ({ service, customPopulateRow }) => {
|
||||||
*/
|
*/
|
||||||
updateSearchMatchesForRow(
|
updateSearchMatchesForRow(
|
||||||
{ commit, getters, rootGetters },
|
{ commit, getters, rootGetters },
|
||||||
{ row, fields, primary = null, overrides, forced = false }
|
{ row, fields, overrides, forced = false }
|
||||||
) {
|
) {
|
||||||
// Avoid computing search on table loading
|
// Avoid computing search on table loading
|
||||||
if (getters.getActiveSearchTerm || forced) {
|
if (getters.getActiveSearchTerm || forced) {
|
||||||
|
@ -990,7 +957,7 @@ export default ({ service, customPopulateRow }) => {
|
||||||
row,
|
row,
|
||||||
getters.getActiveSearchTerm,
|
getters.getActiveSearchTerm,
|
||||||
getters.isHidingRowsNotMatchingSearch,
|
getters.isHidingRowsNotMatchingSearch,
|
||||||
[primary, ...fields],
|
fields,
|
||||||
this.$registry,
|
this.$registry,
|
||||||
overrides
|
overrides
|
||||||
)
|
)
|
||||||
|
|
|
@ -27,11 +27,10 @@ export const mutations = {
|
||||||
}
|
}
|
||||||
|
|
||||||
export const actions = {
|
export const actions = {
|
||||||
async fetchInitial({ dispatch, commit }, { viewId, fields, primary }) {
|
async fetchInitial({ dispatch, commit }, { viewId, fields }) {
|
||||||
const data = await dispatch('fetchInitialRows', {
|
const data = await dispatch('fetchInitialRows', {
|
||||||
viewId,
|
viewId,
|
||||||
fields,
|
fields,
|
||||||
primary,
|
|
||||||
initialRowArguments: { includeFieldOptions: true },
|
initialRowArguments: { includeFieldOptions: true },
|
||||||
})
|
})
|
||||||
await dispatch('forceUpdateAllFieldOptions', data.field_options)
|
await dispatch('forceUpdateAllFieldOptions', data.field_options)
|
||||||
|
|
|
@ -506,7 +506,7 @@ export const actions = {
|
||||||
*/
|
*/
|
||||||
fetchByScrollTop(
|
fetchByScrollTop(
|
||||||
{ commit, getters, rootGetters, dispatch },
|
{ commit, getters, rootGetters, dispatch },
|
||||||
{ scrollTop, fields, primary }
|
{ scrollTop, fields }
|
||||||
) {
|
) {
|
||||||
const windowHeight = getters.getWindowHeight
|
const windowHeight = getters.getWindowHeight
|
||||||
const gridId = getters.getLastGridId
|
const gridId = getters.getLastGridId
|
||||||
|
@ -630,7 +630,7 @@ export const actions = {
|
||||||
bufferLimit,
|
bufferLimit,
|
||||||
})
|
})
|
||||||
dispatch('visibleByScrollTop')
|
dispatch('visibleByScrollTop')
|
||||||
dispatch('updateSearch', { fields, primary })
|
dispatch('updateSearch', { fields })
|
||||||
lastRequest = null
|
lastRequest = null
|
||||||
fireScrollTop.processing = false
|
fireScrollTop.processing = false
|
||||||
})
|
})
|
||||||
|
@ -715,7 +715,7 @@ export const actions = {
|
||||||
* of calls. Therefore it will dispatch the related actions, but only every 100
|
* of calls. Therefore it will dispatch the related actions, but only every 100
|
||||||
* milliseconds to prevent calling the actions who do a lot of calculating a lot.
|
* milliseconds to prevent calling the actions who do a lot of calculating a lot.
|
||||||
*/
|
*/
|
||||||
fetchByScrollTopDelayed({ dispatch }, { scrollTop, fields, primary }) {
|
fetchByScrollTopDelayed({ dispatch }, { scrollTop, fields }) {
|
||||||
const now = Date.now()
|
const now = Date.now()
|
||||||
|
|
||||||
const fire = (scrollTop) => {
|
const fire = (scrollTop) => {
|
||||||
|
@ -724,7 +724,6 @@ export const actions = {
|
||||||
dispatch('fetchByScrollTop', {
|
dispatch('fetchByScrollTop', {
|
||||||
scrollTop,
|
scrollTop,
|
||||||
fields,
|
fields,
|
||||||
primary,
|
|
||||||
})
|
})
|
||||||
dispatch('visibleByScrollTop', scrollTop)
|
dispatch('visibleByScrollTop', scrollTop)
|
||||||
}
|
}
|
||||||
|
@ -753,7 +752,7 @@ export const actions = {
|
||||||
*/
|
*/
|
||||||
async fetchInitial(
|
async fetchInitial(
|
||||||
{ dispatch, commit, getters, rootGetters },
|
{ dispatch, commit, getters, rootGetters },
|
||||||
{ gridId, fields, primary }
|
{ gridId, fields }
|
||||||
) {
|
) {
|
||||||
// Reset scrollTop when switching table
|
// Reset scrollTop when switching table
|
||||||
fireScrollTop.distance = 0
|
fireScrollTop.distance = 0
|
||||||
|
@ -798,7 +797,7 @@ export const actions = {
|
||||||
top: 0,
|
top: 0,
|
||||||
})
|
})
|
||||||
commit('REPLACE_ALL_FIELD_OPTIONS', data.field_options)
|
commit('REPLACE_ALL_FIELD_OPTIONS', data.field_options)
|
||||||
dispatch('updateSearch', { fields, primary })
|
dispatch('updateSearch', { fields })
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* Refreshes the current state with fresh data. It keeps the scroll offset the same
|
* Refreshes the current state with fresh data. It keeps the scroll offset the same
|
||||||
|
@ -808,7 +807,7 @@ export const actions = {
|
||||||
*/
|
*/
|
||||||
refresh(
|
refresh(
|
||||||
{ dispatch, commit, getters, rootGetters },
|
{ dispatch, commit, getters, rootGetters },
|
||||||
{ view, fields, primary, includeFieldOptions = false }
|
{ view, fields, includeFieldOptions = false }
|
||||||
) {
|
) {
|
||||||
const gridId = getters.getLastGridId
|
const gridId = getters.getLastGridId
|
||||||
|
|
||||||
|
@ -869,7 +868,7 @@ export const actions = {
|
||||||
bufferStartIndex: offset,
|
bufferStartIndex: offset,
|
||||||
bufferLimit: data.results.length,
|
bufferLimit: data.results.length,
|
||||||
})
|
})
|
||||||
dispatch('updateSearch', { fields, primary })
|
dispatch('updateSearch', { fields })
|
||||||
if (includeFieldOptions) {
|
if (includeFieldOptions) {
|
||||||
if (getters.isPublic) {
|
if (getters.isPublic) {
|
||||||
// If the view is public, then we're in read only mode and we want to
|
// If the view is public, then we're in read only mode and we want to
|
||||||
|
@ -1281,10 +1280,10 @@ export const actions = {
|
||||||
*/
|
*/
|
||||||
removeRowSelectedBy(
|
removeRowSelectedBy(
|
||||||
{ dispatch, commit },
|
{ dispatch, commit },
|
||||||
{ grid, row, field, fields, primary, getScrollTop }
|
{ grid, row, field, fields, getScrollTop }
|
||||||
) {
|
) {
|
||||||
commit('REMOVE_ROW_SELECTED_BY', { row, fieldId: field.id })
|
commit('REMOVE_ROW_SELECTED_BY', { row, fieldId: field.id })
|
||||||
dispatch('refreshRow', { grid, row, fields, primary, getScrollTop })
|
dispatch('refreshRow', { grid, row, fields, getScrollTop })
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* Called when the user wants to create a new row. Optionally a `before` row
|
* Called when the user wants to create a new row. Optionally a `before` row
|
||||||
|
@ -1293,13 +1292,12 @@ export const actions = {
|
||||||
*/
|
*/
|
||||||
async createNewRow(
|
async createNewRow(
|
||||||
{ commit, getters, dispatch },
|
{ commit, getters, dispatch },
|
||||||
{ view, table, fields, primary, values = {}, before = null }
|
{ view, table, fields, values = {}, before = null }
|
||||||
) {
|
) {
|
||||||
// Fill the not provided values with the empty value of the field type so we can
|
// Fill the not provided values with the empty value of the field type so we can
|
||||||
// immediately commit the created row to the state.
|
// immediately commit the created row to the state.
|
||||||
const valuesForApiRequest = {}
|
const valuesForApiRequest = {}
|
||||||
const allFields = [primary].concat(fields)
|
fields.forEach((field) => {
|
||||||
allFields.forEach((field) => {
|
|
||||||
const name = `field_${field.id}`
|
const name = `field_${field.id}`
|
||||||
const fieldType = this.$registry.get('field', field._.type.type)
|
const fieldType = this.$registry.get('field', field._.type.type)
|
||||||
if (!(name in values)) {
|
if (!(name in values)) {
|
||||||
|
@ -1353,7 +1351,7 @@ export const actions = {
|
||||||
order: data.order,
|
order: data.order,
|
||||||
values: data,
|
values: data,
|
||||||
})
|
})
|
||||||
dispatch('onRowChange', { view, row, fields, primary })
|
dispatch('onRowChange', { view, row, fields })
|
||||||
dispatch('fetchAllFieldAggregationData', {
|
dispatch('fetchAllFieldAggregationData', {
|
||||||
view,
|
view,
|
||||||
})
|
})
|
||||||
|
@ -1369,15 +1367,15 @@ export const actions = {
|
||||||
*/
|
*/
|
||||||
createdNewRow(
|
createdNewRow(
|
||||||
{ commit, getters, dispatch },
|
{ commit, getters, dispatch },
|
||||||
{ view, fields, primary, values, metadata }
|
{ view, fields, values, metadata }
|
||||||
) {
|
) {
|
||||||
const row = clone(values)
|
const row = clone(values)
|
||||||
populateRow(row, metadata)
|
populateRow(row, metadata)
|
||||||
|
|
||||||
// Check if the row belongs into the current view by checking if it matches the
|
// Check if the row belongs into the current view by checking if it matches the
|
||||||
// filters and search.
|
// filters and search.
|
||||||
dispatch('updateMatchFilters', { view, row, fields, primary })
|
dispatch('updateMatchFilters', { view, row, fields })
|
||||||
dispatch('updateSearchMatchesForRow', { row, fields, primary })
|
dispatch('updateSearchMatchesForRow', { row, fields })
|
||||||
|
|
||||||
// If the row does not match the filters or the search then we don't have to add
|
// If the row does not match the filters or the search then we don't have to add
|
||||||
// it at all.
|
// it at all.
|
||||||
|
@ -1392,8 +1390,7 @@ export const actions = {
|
||||||
const sortFunction = getRowSortFunction(
|
const sortFunction = getRowSortFunction(
|
||||||
this.$registry,
|
this.$registry,
|
||||||
view.sortings,
|
view.sortings,
|
||||||
fields,
|
fields
|
||||||
primary
|
|
||||||
)
|
)
|
||||||
allRowsCopy.sort(sortFunction)
|
allRowsCopy.sort(sortFunction)
|
||||||
const index = allRowsCopy.findIndex((r) => r.id === row.id)
|
const index = allRowsCopy.findIndex((r) => r.id === row.id)
|
||||||
|
@ -1427,7 +1424,7 @@ export const actions = {
|
||||||
*/
|
*/
|
||||||
async moveRow(
|
async moveRow(
|
||||||
{ commit, dispatch, getters },
|
{ commit, dispatch, getters },
|
||||||
{ table, grid, fields, primary, getScrollTop, row, before = null }
|
{ table, grid, fields, getScrollTop, row, before = null }
|
||||||
) {
|
) {
|
||||||
const oldOrder = row.order
|
const oldOrder = row.order
|
||||||
|
|
||||||
|
@ -1447,7 +1444,7 @@ export const actions = {
|
||||||
|
|
||||||
// In order to make changes feel really fast, we optimistically
|
// In order to make changes feel really fast, we optimistically
|
||||||
// updated all the field values that provide a onRowMove function
|
// updated all the field values that provide a onRowMove function
|
||||||
const fieldsToCallOnRowMove = [...fields, primary]
|
const fieldsToCallOnRowMove = fields
|
||||||
const optimisticFieldValues = {}
|
const optimisticFieldValues = {}
|
||||||
const valuesBeforeOptimisticUpdate = {}
|
const valuesBeforeOptimisticUpdate = {}
|
||||||
|
|
||||||
|
@ -1471,7 +1468,6 @@ export const actions = {
|
||||||
dispatch('updatedExistingRow', {
|
dispatch('updatedExistingRow', {
|
||||||
view: grid,
|
view: grid,
|
||||||
fields,
|
fields,
|
||||||
primary,
|
|
||||||
row,
|
row,
|
||||||
values: { order, ...optimisticFieldValues },
|
values: { order, ...optimisticFieldValues },
|
||||||
})
|
})
|
||||||
|
@ -1494,14 +1490,12 @@ export const actions = {
|
||||||
dispatch('fetchByScrollTopDelayed', {
|
dispatch('fetchByScrollTopDelayed', {
|
||||||
scrollTop: getScrollTop(),
|
scrollTop: getScrollTop(),
|
||||||
fields,
|
fields,
|
||||||
primary,
|
|
||||||
})
|
})
|
||||||
dispatch('fetchAllFieldAggregationData', { view: grid })
|
dispatch('fetchAllFieldAggregationData', { view: grid })
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
dispatch('updatedExistingRow', {
|
dispatch('updatedExistingRow', {
|
||||||
view: grid,
|
view: grid,
|
||||||
fields,
|
fields,
|
||||||
primary,
|
|
||||||
row,
|
row,
|
||||||
values: { order: oldOrder, ...valuesBeforeOptimisticUpdate },
|
values: { order: oldOrder, ...valuesBeforeOptimisticUpdate },
|
||||||
})
|
})
|
||||||
|
@ -1515,7 +1509,7 @@ export const actions = {
|
||||||
*/
|
*/
|
||||||
async updateRowValue(
|
async updateRowValue(
|
||||||
{ commit, dispatch },
|
{ commit, dispatch },
|
||||||
{ table, view, row, field, fields, primary, value, oldValue }
|
{ table, view, row, field, fields, value, oldValue }
|
||||||
) {
|
) {
|
||||||
// Immediately updated the store with the updated row field
|
// Immediately updated the store with the updated row field
|
||||||
// value.
|
// value.
|
||||||
|
@ -1528,7 +1522,7 @@ export const actions = {
|
||||||
// in case we need to rollback changes
|
// in case we need to rollback changes
|
||||||
valuesBeforeOptimisticUpdate[`field_${field.id}`] = oldValue
|
valuesBeforeOptimisticUpdate[`field_${field.id}`] = oldValue
|
||||||
|
|
||||||
let fieldsToCallOnRowChange = [...fields, primary]
|
let fieldsToCallOnRowChange = fields
|
||||||
|
|
||||||
// We already added the updated field values to the store
|
// We already added the updated field values to the store
|
||||||
// so we can remove the field from our fieldsToCallOnRowChange
|
// so we can remove the field from our fieldsToCallOnRowChange
|
||||||
|
@ -1555,7 +1549,7 @@ export const actions = {
|
||||||
row,
|
row,
|
||||||
values: { ...optimisticFieldValues },
|
values: { ...optimisticFieldValues },
|
||||||
})
|
})
|
||||||
dispatch('onRowChange', { view, row, fields, primary })
|
dispatch('onRowChange', { view, row, fields })
|
||||||
|
|
||||||
const fieldType = this.$registry.get('field', field._.type.type)
|
const fieldType = this.$registry.get('field', field._.type.type)
|
||||||
const newValue = fieldType.prepareValueForUpdate(field, value)
|
const newValue = fieldType.prepareValueForUpdate(field, value)
|
||||||
|
@ -1569,7 +1563,7 @@ export const actions = {
|
||||||
values
|
values
|
||||||
)
|
)
|
||||||
commit('UPDATE_ROW_IN_BUFFER', { row, values: updatedRow.data })
|
commit('UPDATE_ROW_IN_BUFFER', { row, values: updatedRow.data })
|
||||||
dispatch('onRowChange', { view, row, fields, primary })
|
dispatch('onRowChange', { view, row, fields })
|
||||||
dispatch('fetchAllFieldAggregationData', {
|
dispatch('fetchAllFieldAggregationData', {
|
||||||
view,
|
view,
|
||||||
})
|
})
|
||||||
|
@ -1579,7 +1573,7 @@ export const actions = {
|
||||||
values: { ...valuesBeforeOptimisticUpdate },
|
values: { ...valuesBeforeOptimisticUpdate },
|
||||||
})
|
})
|
||||||
|
|
||||||
dispatch('onRowChange', { view, row, fields, primary })
|
dispatch('onRowChange', { view, row, fields })
|
||||||
throw error
|
throw error
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -1590,7 +1584,7 @@ export const actions = {
|
||||||
*/
|
*/
|
||||||
async updateDataIntoCells(
|
async updateDataIntoCells(
|
||||||
{ getters, commit, dispatch },
|
{ getters, commit, dispatch },
|
||||||
{ table, view, primary, fields, getScrollTop, data, rowIndex, fieldIndex }
|
{ table, view, fields, getScrollTop, data, rowIndex, fieldIndex }
|
||||||
) {
|
) {
|
||||||
// If the origin origin row and field index are not provided, we need to use the
|
// If the origin origin row and field index are not provided, we need to use the
|
||||||
// head indexes of the multiple select.
|
// head indexes of the multiple select.
|
||||||
|
@ -1703,7 +1697,6 @@ export const actions = {
|
||||||
await dispatch('updatedExistingRow', {
|
await dispatch('updatedExistingRow', {
|
||||||
view,
|
view,
|
||||||
fields,
|
fields,
|
||||||
primary,
|
|
||||||
row,
|
row,
|
||||||
values,
|
values,
|
||||||
})
|
})
|
||||||
|
@ -1714,7 +1707,6 @@ export const actions = {
|
||||||
await dispatch('fetchByScrollTopDelayed', {
|
await dispatch('fetchByScrollTopDelayed', {
|
||||||
scrollTop: getScrollTop(),
|
scrollTop: getScrollTop(),
|
||||||
fields,
|
fields,
|
||||||
primary,
|
|
||||||
})
|
})
|
||||||
dispatch('fetchAllFieldAggregationData', { view })
|
dispatch('fetchAllFieldAggregationData', { view })
|
||||||
},
|
},
|
||||||
|
@ -1725,29 +1717,28 @@ export const actions = {
|
||||||
*/
|
*/
|
||||||
updatedExistingRow(
|
updatedExistingRow(
|
||||||
{ commit, getters, dispatch },
|
{ commit, getters, dispatch },
|
||||||
{ view, fields, primary, row, values, metadata }
|
{ view, fields, row, values, metadata }
|
||||||
) {
|
) {
|
||||||
const oldRow = clone(row)
|
const oldRow = clone(row)
|
||||||
const newRow = Object.assign(clone(row), values)
|
const newRow = Object.assign(clone(row), values)
|
||||||
populateRow(oldRow, metadata)
|
populateRow(oldRow, metadata)
|
||||||
populateRow(newRow, metadata)
|
populateRow(newRow, metadata)
|
||||||
|
|
||||||
dispatch('updateMatchFilters', { view, row: oldRow, fields, primary })
|
dispatch('updateMatchFilters', { view, row: oldRow, fields })
|
||||||
dispatch('updateSearchMatchesForRow', { row: oldRow, fields, primary })
|
dispatch('updateSearchMatchesForRow', { row: oldRow, fields })
|
||||||
|
|
||||||
dispatch('updateMatchFilters', { view, row: newRow, fields, primary })
|
dispatch('updateMatchFilters', { view, row: newRow, fields })
|
||||||
dispatch('updateSearchMatchesForRow', { row: newRow, fields, primary })
|
dispatch('updateSearchMatchesForRow', { row: newRow, fields })
|
||||||
|
|
||||||
const oldRowExists = oldRow._.matchFilters && oldRow._.matchSearch
|
const oldRowExists = oldRow._.matchFilters && oldRow._.matchSearch
|
||||||
const newRowExists = newRow._.matchFilters && newRow._.matchSearch
|
const newRowExists = newRow._.matchFilters && newRow._.matchSearch
|
||||||
|
|
||||||
if (oldRowExists && !newRowExists) {
|
if (oldRowExists && !newRowExists) {
|
||||||
dispatch('deletedExistingRow', { view, fields, primary, row })
|
dispatch('deletedExistingRow', { view, fields, row })
|
||||||
} else if (!oldRowExists && newRowExists) {
|
} else if (!oldRowExists && newRowExists) {
|
||||||
dispatch('createdNewRow', {
|
dispatch('createdNewRow', {
|
||||||
view,
|
view,
|
||||||
fields,
|
fields,
|
||||||
primary,
|
|
||||||
values: newRow,
|
values: newRow,
|
||||||
metadata,
|
metadata,
|
||||||
})
|
})
|
||||||
|
@ -1767,8 +1758,7 @@ export const actions = {
|
||||||
const sortFunction = getRowSortFunction(
|
const sortFunction = getRowSortFunction(
|
||||||
this.$registry,
|
this.$registry,
|
||||||
view.sortings,
|
view.sortings,
|
||||||
fields,
|
fields
|
||||||
primary
|
|
||||||
)
|
)
|
||||||
const allRows = getters.getAllRows
|
const allRows = getters.getAllRows
|
||||||
const index = allRows.findIndex((r) => r.id === row.id)
|
const index = allRows.findIndex((r) => r.id === row.id)
|
||||||
|
@ -1858,7 +1848,7 @@ export const actions = {
|
||||||
*/
|
*/
|
||||||
async deleteExistingRow(
|
async deleteExistingRow(
|
||||||
{ commit, dispatch, getters },
|
{ commit, dispatch, getters },
|
||||||
{ table, view, row, fields, primary, getScrollTop }
|
{ table, view, row, fields, getScrollTop }
|
||||||
) {
|
) {
|
||||||
commit('SET_ROW_LOADING', { row, value: true })
|
commit('SET_ROW_LOADING', { row, value: true })
|
||||||
|
|
||||||
|
@ -1867,14 +1857,12 @@ export const actions = {
|
||||||
await dispatch('deletedExistingRow', {
|
await dispatch('deletedExistingRow', {
|
||||||
view,
|
view,
|
||||||
fields,
|
fields,
|
||||||
primary,
|
|
||||||
row,
|
row,
|
||||||
getScrollTop,
|
getScrollTop,
|
||||||
})
|
})
|
||||||
await dispatch('fetchByScrollTopDelayed', {
|
await dispatch('fetchByScrollTopDelayed', {
|
||||||
scrollTop: getScrollTop(),
|
scrollTop: getScrollTop(),
|
||||||
fields,
|
fields,
|
||||||
primary,
|
|
||||||
})
|
})
|
||||||
dispatch('fetchAllFieldAggregationData', { view })
|
dispatch('fetchAllFieldAggregationData', { view })
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
@ -1887,7 +1875,7 @@ export const actions = {
|
||||||
*/
|
*/
|
||||||
async deleteSelectedRows(
|
async deleteSelectedRows(
|
||||||
{ dispatch, getters },
|
{ dispatch, getters },
|
||||||
{ table, view, fields, primary, getScrollTop }
|
{ table, view, fields, getScrollTop }
|
||||||
) {
|
) {
|
||||||
if (!getters.isMultiSelectActive) {
|
if (!getters.isMultiSelectActive) {
|
||||||
return
|
return
|
||||||
|
@ -1913,7 +1901,6 @@ export const actions = {
|
||||||
await dispatch('deletedExistingRow', {
|
await dispatch('deletedExistingRow', {
|
||||||
view,
|
view,
|
||||||
fields,
|
fields,
|
||||||
primary,
|
|
||||||
row,
|
row,
|
||||||
getScrollTop,
|
getScrollTop,
|
||||||
})
|
})
|
||||||
|
@ -1922,7 +1909,6 @@ export const actions = {
|
||||||
await dispatch('fetchByScrollTopDelayed', {
|
await dispatch('fetchByScrollTopDelayed', {
|
||||||
scrollTop: getScrollTop(),
|
scrollTop: getScrollTop(),
|
||||||
fields,
|
fields,
|
||||||
primary,
|
|
||||||
})
|
})
|
||||||
dispatch('fetchAllFieldAggregationData', { view })
|
dispatch('fetchAllFieldAggregationData', { view })
|
||||||
},
|
},
|
||||||
|
@ -1930,16 +1916,13 @@ export const actions = {
|
||||||
* Called after an existing row has been deleted, which could be by the user or
|
* Called after an existing row has been deleted, which could be by the user or
|
||||||
* via another channel.
|
* via another channel.
|
||||||
*/
|
*/
|
||||||
deletedExistingRow(
|
deletedExistingRow({ commit, getters, dispatch }, { view, fields, row }) {
|
||||||
{ commit, getters, dispatch },
|
|
||||||
{ view, fields, primary, row }
|
|
||||||
) {
|
|
||||||
row = clone(row)
|
row = clone(row)
|
||||||
populateRow(row)
|
populateRow(row)
|
||||||
|
|
||||||
// Check if that row was visible in the view.
|
// Check if that row was visible in the view.
|
||||||
dispatch('updateMatchFilters', { view, row, fields, primary })
|
dispatch('updateMatchFilters', { view, row, fields })
|
||||||
dispatch('updateSearchMatchesForRow', { row, fields, primary })
|
dispatch('updateSearchMatchesForRow', { row, fields })
|
||||||
|
|
||||||
// If the row does not match the filters or the search then did not exist in the
|
// If the row does not match the filters or the search then did not exist in the
|
||||||
// view, so we don't have to do anything.
|
// view, so we don't have to do anything.
|
||||||
|
@ -1965,8 +1948,7 @@ export const actions = {
|
||||||
const sortFunction = getRowSortFunction(
|
const sortFunction = getRowSortFunction(
|
||||||
this.$registry,
|
this.$registry,
|
||||||
view.sortings,
|
view.sortings,
|
||||||
fields,
|
fields
|
||||||
primary
|
|
||||||
)
|
)
|
||||||
allRowsCopy.sort(sortFunction)
|
allRowsCopy.sort(sortFunction)
|
||||||
const index = allRowsCopy.findIndex((r) => r.id === row.id)
|
const index = allRowsCopy.findIndex((r) => r.id === row.id)
|
||||||
|
@ -1984,20 +1966,17 @@ export const actions = {
|
||||||
* Triggered when a row has been changed, or has a pending change in the provided
|
* Triggered when a row has been changed, or has a pending change in the provided
|
||||||
* overrides.
|
* overrides.
|
||||||
*/
|
*/
|
||||||
onRowChange({ dispatch }, { view, row, fields, primary, overrides = {} }) {
|
onRowChange({ dispatch }, { view, row, fields, overrides = {} }) {
|
||||||
dispatch('updateMatchFilters', { view, row, fields, primary, overrides })
|
dispatch('updateMatchFilters', { view, row, fields, overrides })
|
||||||
dispatch('updateMatchSortings', { view, row, fields, primary, overrides })
|
dispatch('updateMatchSortings', { view, row, fields, overrides })
|
||||||
dispatch('updateSearchMatchesForRow', { row, fields, primary, overrides })
|
dispatch('updateSearchMatchesForRow', { row, fields, overrides })
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* Checks if the given row still matches the given view filters. The row's
|
* Checks if the given row still matches the given view filters. The row's
|
||||||
* matchFilters value is updated accordingly. It is also possible to provide some
|
* matchFilters value is updated accordingly. It is also possible to provide some
|
||||||
* override values that not actually belong to the row to do some preliminary checks.
|
* override values that not actually belong to the row to do some preliminary checks.
|
||||||
*/
|
*/
|
||||||
updateMatchFilters(
|
updateMatchFilters({ commit }, { view, row, fields, overrides = {} }) {
|
||||||
{ commit },
|
|
||||||
{ view, row, fields, primary, overrides = {} }
|
|
||||||
) {
|
|
||||||
const values = JSON.parse(JSON.stringify(row))
|
const values = JSON.parse(JSON.stringify(row))
|
||||||
Object.assign(values, overrides)
|
Object.assign(values, overrides)
|
||||||
|
|
||||||
|
@ -2008,7 +1987,7 @@ export const actions = {
|
||||||
this.$registry,
|
this.$registry,
|
||||||
view.filter_type,
|
view.filter_type,
|
||||||
view.filters,
|
view.filters,
|
||||||
primary === null ? fields : [primary, ...fields],
|
fields,
|
||||||
values
|
values
|
||||||
)
|
)
|
||||||
commit('SET_ROW_MATCH_FILTERS', { row, value: matches })
|
commit('SET_ROW_MATCH_FILTERS', { row, value: matches })
|
||||||
|
@ -2022,7 +2001,6 @@ export const actions = {
|
||||||
{ commit, dispatch, getters, state },
|
{ commit, dispatch, getters, state },
|
||||||
{
|
{
|
||||||
fields,
|
fields,
|
||||||
primary = null,
|
|
||||||
activeSearchTerm = state.activeSearchTerm,
|
activeSearchTerm = state.activeSearchTerm,
|
||||||
hideRowsNotMatchingSearch = state.hideRowsNotMatchingSearch,
|
hideRowsNotMatchingSearch = state.hideRowsNotMatchingSearch,
|
||||||
refreshMatchesOnClient = true,
|
refreshMatchesOnClient = true,
|
||||||
|
@ -2034,7 +2012,6 @@ export const actions = {
|
||||||
dispatch('updateSearchMatchesForRow', {
|
dispatch('updateSearchMatchesForRow', {
|
||||||
row,
|
row,
|
||||||
fields,
|
fields,
|
||||||
primary,
|
|
||||||
forced: true,
|
forced: true,
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
|
@ -2047,7 +2024,7 @@ export const actions = {
|
||||||
*/
|
*/
|
||||||
updateSearchMatchesForRow(
|
updateSearchMatchesForRow(
|
||||||
{ commit, getters, rootGetters },
|
{ commit, getters, rootGetters },
|
||||||
{ row, fields, primary = null, overrides, forced = false }
|
{ row, fields = null, overrides, forced = false }
|
||||||
) {
|
) {
|
||||||
// Avoid computing search on table loading
|
// Avoid computing search on table loading
|
||||||
if (getters.getActiveSearchTerm || forced) {
|
if (getters.getActiveSearchTerm || forced) {
|
||||||
|
@ -2055,7 +2032,7 @@ export const actions = {
|
||||||
row,
|
row,
|
||||||
getters.getActiveSearchTerm,
|
getters.getActiveSearchTerm,
|
||||||
getters.isHidingRowsNotMatchingSearch,
|
getters.isHidingRowsNotMatchingSearch,
|
||||||
[primary, ...fields],
|
fields,
|
||||||
this.$registry,
|
this.$registry,
|
||||||
overrides
|
overrides
|
||||||
)
|
)
|
||||||
|
@ -2070,7 +2047,7 @@ export const actions = {
|
||||||
*/
|
*/
|
||||||
updateMatchSortings(
|
updateMatchSortings(
|
||||||
{ commit, getters },
|
{ commit, getters },
|
||||||
{ view, row, fields, primary = null, overrides = {} }
|
{ view, row, fields, overrides = {} }
|
||||||
) {
|
) {
|
||||||
const values = clone(row)
|
const values = clone(row)
|
||||||
Object.assign(values, overrides)
|
Object.assign(values, overrides)
|
||||||
|
@ -2079,9 +2056,7 @@ export const actions = {
|
||||||
const currentIndex = getters.getAllRows.findIndex((r) => r.id === row.id)
|
const currentIndex = getters.getAllRows.findIndex((r) => r.id === row.id)
|
||||||
const sortedRows = clone(allRows)
|
const sortedRows = clone(allRows)
|
||||||
sortedRows[currentIndex] = values
|
sortedRows[currentIndex] = values
|
||||||
sortedRows.sort(
|
sortedRows.sort(getRowSortFunction(this.$registry, view.sortings, fields))
|
||||||
getRowSortFunction(this.$registry, view.sortings, fields, primary)
|
|
||||||
)
|
|
||||||
const newIndex = sortedRows.findIndex((r) => r.id === row.id)
|
const newIndex = sortedRows.findIndex((r) => r.id === row.id)
|
||||||
|
|
||||||
commit('SET_ROW_MATCH_SORTINGS', { row, value: currentIndex === newIndex })
|
commit('SET_ROW_MATCH_SORTINGS', { row, value: currentIndex === newIndex })
|
||||||
|
@ -2092,7 +2067,7 @@ export const actions = {
|
||||||
*/
|
*/
|
||||||
async refreshRow(
|
async refreshRow(
|
||||||
{ dispatch, commit, getters },
|
{ dispatch, commit, getters },
|
||||||
{ grid, row, fields, primary, getScrollTop }
|
{ grid, row, fields, getScrollTop }
|
||||||
) {
|
) {
|
||||||
const rowShouldBeHidden = !row._.matchFilters || !row._.matchSearch
|
const rowShouldBeHidden = !row._.matchFilters || !row._.matchSearch
|
||||||
if (row._.selectedBy.length === 0 && rowShouldBeHidden) {
|
if (row._.selectedBy.length === 0 && rowShouldBeHidden) {
|
||||||
|
@ -2101,7 +2076,6 @@ export const actions = {
|
||||||
await dispatch('updatedExistingRow', {
|
await dispatch('updatedExistingRow', {
|
||||||
view: grid,
|
view: grid,
|
||||||
fields,
|
fields,
|
||||||
primary,
|
|
||||||
row,
|
row,
|
||||||
values: row,
|
values: row,
|
||||||
})
|
})
|
||||||
|
@ -2110,7 +2084,6 @@ export const actions = {
|
||||||
dispatch('fetchByScrollTopDelayed', {
|
dispatch('fetchByScrollTopDelayed', {
|
||||||
scrollTop: getScrollTop(),
|
scrollTop: getScrollTop(),
|
||||||
fields,
|
fields,
|
||||||
primary,
|
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
updateRowMetadata(
|
updateRowMetadata(
|
||||||
|
@ -2130,7 +2103,7 @@ export const actions = {
|
||||||
*/
|
*/
|
||||||
async clearValuesFromMultipleCellSelection(
|
async clearValuesFromMultipleCellSelection(
|
||||||
{ getters, dispatch },
|
{ getters, dispatch },
|
||||||
{ table, view, primary, fields, getScrollTop }
|
{ table, view, fields, getScrollTop }
|
||||||
) {
|
) {
|
||||||
const [minFieldIndex, maxFieldIndex] =
|
const [minFieldIndex, maxFieldIndex] =
|
||||||
getters.getMultiSelectFieldIndexSorted
|
getters.getMultiSelectFieldIndexSorted
|
||||||
|
@ -2156,7 +2129,6 @@ export const actions = {
|
||||||
await dispatch('updateDataIntoCells', {
|
await dispatch('updateDataIntoCells', {
|
||||||
table,
|
table,
|
||||||
view,
|
view,
|
||||||
primary,
|
|
||||||
fields,
|
fields,
|
||||||
getScrollTop,
|
getScrollTop,
|
||||||
data,
|
data,
|
||||||
|
|
10
web-frontend/modules/database/utils/field.js
Normal file
10
web-frontend/modules/database/utils/field.js
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
/**
|
||||||
|
* Find the primary field in a list of fields.
|
||||||
|
* If no primary field is found, return the first field.
|
||||||
|
* @param fields
|
||||||
|
* @returns {*}
|
||||||
|
*/
|
||||||
|
export function getPrimaryOrFirstField(fields) {
|
||||||
|
const primaryField = fields.find((field) => field.primary)
|
||||||
|
return primaryField || fields[0]
|
||||||
|
}
|
|
@ -5,20 +5,12 @@ import { maxPossibleOrderValue } from '@baserow/modules/database/viewTypes'
|
||||||
/**
|
/**
|
||||||
* Generates a sort function based on the provided sortings.
|
* Generates a sort function based on the provided sortings.
|
||||||
*/
|
*/
|
||||||
export function getRowSortFunction(
|
export function getRowSortFunction($registry, sortings, fields) {
|
||||||
$registry,
|
|
||||||
sortings,
|
|
||||||
fields,
|
|
||||||
primary = null
|
|
||||||
) {
|
|
||||||
let sortFunction = firstBy()
|
let sortFunction = firstBy()
|
||||||
|
|
||||||
sortings.forEach((sort) => {
|
sortings.forEach((sort) => {
|
||||||
// Find the field that is related to the sort.
|
// Find the field that is related to the sort.
|
||||||
let field = fields.find((f) => f.id === sort.field)
|
const field = fields.find((f) => f.id === sort.field)
|
||||||
if (field === undefined && primary !== null && primary.id === sort.field) {
|
|
||||||
field = primary
|
|
||||||
}
|
|
||||||
|
|
||||||
if (field !== undefined) {
|
if (field !== undefined) {
|
||||||
const fieldName = `field_${field.id}`
|
const fieldName = `field_${field.id}`
|
||||||
|
|
|
@ -170,7 +170,6 @@ export class ViewType extends Registerable {
|
||||||
context,
|
context,
|
||||||
view,
|
view,
|
||||||
fields,
|
fields,
|
||||||
primary,
|
|
||||||
storePrefix = '',
|
storePrefix = '',
|
||||||
includeFieldOptions = false
|
includeFieldOptions = false
|
||||||
) {}
|
) {}
|
||||||
|
@ -228,38 +227,21 @@ export class ViewType extends Registerable {
|
||||||
* via a real time event by another user. It can be used to check if data in an store
|
* via a real time event by another user. It can be used to check if data in an store
|
||||||
* needs to be updated.
|
* needs to be updated.
|
||||||
*/
|
*/
|
||||||
rowCreated(
|
rowCreated(context, tableId, fields, values, metadata, storePrefix) {}
|
||||||
context,
|
|
||||||
tableId,
|
|
||||||
fields,
|
|
||||||
primary,
|
|
||||||
values,
|
|
||||||
metadata,
|
|
||||||
storePrefix
|
|
||||||
) {}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Event that is called when a row is updated from an outside source, so for example
|
* Event that is called when a row is updated from an outside source, so for example
|
||||||
* via a real time event by another user. It can be used to check if data in an store
|
* via a real time event by another user. It can be used to check if data in an store
|
||||||
* needs to be updated.
|
* needs to be updated.
|
||||||
*/
|
*/
|
||||||
rowUpdated(
|
rowUpdated(context, tableId, fields, row, values, metadata, storePrefix) {}
|
||||||
context,
|
|
||||||
tableId,
|
|
||||||
fields,
|
|
||||||
primary,
|
|
||||||
row,
|
|
||||||
values,
|
|
||||||
metadata,
|
|
||||||
storePrefix
|
|
||||||
) {}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Event that is called when a row is deleted from an outside source, so for example
|
* Event that is called when a row is deleted from an outside source, so for example
|
||||||
* via a real time event by another user. It can be used to check if data in an store
|
* via a real time event by another user. It can be used to check if data in an store
|
||||||
* needs to be updated.
|
* needs to be updated.
|
||||||
*/
|
*/
|
||||||
rowDeleted(context, tableId, fields, primary, row, storePrefix) {}
|
rowDeleted(context, tableId, fields, row, storePrefix) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Event that is called when a piece of metadata is updated for a particular row.
|
* Event that is called when a piece of metadata is updated for a particular row.
|
||||||
|
@ -357,11 +339,10 @@ export class GridViewType extends ViewType {
|
||||||
return 'database-public-grid-view'
|
return 'database-public-grid-view'
|
||||||
}
|
}
|
||||||
|
|
||||||
async fetch({ store }, view, fields, primary, storePrefix = '') {
|
async fetch({ store }, view, fields, storePrefix = '') {
|
||||||
await store.dispatch(storePrefix + 'view/grid/fetchInitial', {
|
await store.dispatch(storePrefix + 'view/grid/fetchInitial', {
|
||||||
gridId: view.id,
|
gridId: view.id,
|
||||||
fields,
|
fields,
|
||||||
primary,
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -369,14 +350,12 @@ export class GridViewType extends ViewType {
|
||||||
{ store },
|
{ store },
|
||||||
view,
|
view,
|
||||||
fields,
|
fields,
|
||||||
primary,
|
|
||||||
storePrefix = '',
|
storePrefix = '',
|
||||||
includeFieldOptions = false
|
includeFieldOptions = false
|
||||||
) {
|
) {
|
||||||
await store.dispatch(storePrefix + 'view/grid/refresh', {
|
await store.dispatch(storePrefix + 'view/grid/refresh', {
|
||||||
view,
|
view,
|
||||||
fields,
|
fields,
|
||||||
primary,
|
|
||||||
includeFieldOptions,
|
includeFieldOptions,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -460,7 +439,6 @@ export class GridViewType extends ViewType {
|
||||||
storePrefix + 'view/grid/updateSearch',
|
storePrefix + 'view/grid/updateSearch',
|
||||||
{
|
{
|
||||||
fields: rootGetters['field/getAll'],
|
fields: rootGetters['field/getAll'],
|
||||||
primary: rootGetters['field/getPrimary'],
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
root: true,
|
root: true,
|
||||||
|
@ -482,7 +460,6 @@ export class GridViewType extends ViewType {
|
||||||
{ store },
|
{ store },
|
||||||
tableId,
|
tableId,
|
||||||
fields,
|
fields,
|
||||||
primary,
|
|
||||||
values,
|
values,
|
||||||
metadata,
|
metadata,
|
||||||
storePrefix = ''
|
storePrefix = ''
|
||||||
|
@ -491,14 +468,12 @@ export class GridViewType extends ViewType {
|
||||||
await store.dispatch(storePrefix + 'view/grid/createdNewRow', {
|
await store.dispatch(storePrefix + 'view/grid/createdNewRow', {
|
||||||
view: store.getters['view/getSelected'],
|
view: store.getters['view/getSelected'],
|
||||||
fields,
|
fields,
|
||||||
primary,
|
|
||||||
values,
|
values,
|
||||||
metadata,
|
metadata,
|
||||||
})
|
})
|
||||||
await store.dispatch(storePrefix + 'view/grid/fetchByScrollTopDelayed', {
|
await store.dispatch(storePrefix + 'view/grid/fetchByScrollTopDelayed', {
|
||||||
scrollTop: store.getters[storePrefix + 'view/grid/getScrollTop'],
|
scrollTop: store.getters[storePrefix + 'view/grid/getScrollTop'],
|
||||||
fields,
|
fields,
|
||||||
primary,
|
|
||||||
})
|
})
|
||||||
store.dispatch(storePrefix + 'view/grid/fetchAllFieldAggregationData', {
|
store.dispatch(storePrefix + 'view/grid/fetchAllFieldAggregationData', {
|
||||||
view: store.getters['view/getSelected'],
|
view: store.getters['view/getSelected'],
|
||||||
|
@ -510,7 +485,6 @@ export class GridViewType extends ViewType {
|
||||||
{ store },
|
{ store },
|
||||||
tableId,
|
tableId,
|
||||||
fields,
|
fields,
|
||||||
primary,
|
|
||||||
row,
|
row,
|
||||||
values,
|
values,
|
||||||
metadata,
|
metadata,
|
||||||
|
@ -520,7 +494,6 @@ export class GridViewType extends ViewType {
|
||||||
await store.dispatch(storePrefix + 'view/grid/updatedExistingRow', {
|
await store.dispatch(storePrefix + 'view/grid/updatedExistingRow', {
|
||||||
view: store.getters['view/getSelected'],
|
view: store.getters['view/getSelected'],
|
||||||
fields,
|
fields,
|
||||||
primary,
|
|
||||||
row,
|
row,
|
||||||
values,
|
values,
|
||||||
metadata,
|
metadata,
|
||||||
|
@ -528,7 +501,6 @@ export class GridViewType extends ViewType {
|
||||||
await store.dispatch(storePrefix + 'view/grid/fetchByScrollTopDelayed', {
|
await store.dispatch(storePrefix + 'view/grid/fetchByScrollTopDelayed', {
|
||||||
scrollTop: store.getters[storePrefix + 'view/grid/getScrollTop'],
|
scrollTop: store.getters[storePrefix + 'view/grid/getScrollTop'],
|
||||||
fields,
|
fields,
|
||||||
primary,
|
|
||||||
})
|
})
|
||||||
store.dispatch(storePrefix + 'view/grid/fetchAllFieldAggregationData', {
|
store.dispatch(storePrefix + 'view/grid/fetchAllFieldAggregationData', {
|
||||||
view: store.getters['view/getSelected'],
|
view: store.getters['view/getSelected'],
|
||||||
|
@ -536,18 +508,16 @@ export class GridViewType extends ViewType {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async rowDeleted({ store }, tableId, fields, primary, row, storePrefix = '') {
|
async rowDeleted({ store }, tableId, fields, row, storePrefix = '') {
|
||||||
if (this.isCurrentView(store, tableId)) {
|
if (this.isCurrentView(store, tableId)) {
|
||||||
await store.dispatch(storePrefix + 'view/grid/deletedExistingRow', {
|
await store.dispatch(storePrefix + 'view/grid/deletedExistingRow', {
|
||||||
view: store.getters['view/getSelected'],
|
view: store.getters['view/getSelected'],
|
||||||
fields,
|
fields,
|
||||||
primary,
|
|
||||||
row,
|
row,
|
||||||
})
|
})
|
||||||
await store.dispatch(storePrefix + 'view/grid/fetchByScrollTopDelayed', {
|
await store.dispatch(storePrefix + 'view/grid/fetchByScrollTopDelayed', {
|
||||||
scrollTop: store.getters[storePrefix + 'view/grid/getScrollTop'],
|
scrollTop: store.getters[storePrefix + 'view/grid/getScrollTop'],
|
||||||
fields,
|
fields,
|
||||||
primary,
|
|
||||||
})
|
})
|
||||||
store.dispatch(storePrefix + 'view/grid/fetchAllFieldAggregationData', {
|
store.dispatch(storePrefix + 'view/grid/fetchAllFieldAggregationData', {
|
||||||
view: store.getters['view/getSelected'],
|
view: store.getters['view/getSelected'],
|
||||||
|
@ -584,11 +554,10 @@ class BaseBufferedRowView extends ViewType {
|
||||||
return {}
|
return {}
|
||||||
}
|
}
|
||||||
|
|
||||||
async fetch({ store }, view, fields, primary, storePrefix = '') {
|
async fetch({ store }, view, fields, storePrefix = '') {
|
||||||
await store.dispatch(`${storePrefix}view/${this.getType()}/fetchInitial`, {
|
await store.dispatch(`${storePrefix}view/${this.getType()}/fetchInitial`, {
|
||||||
viewId: view.id,
|
viewId: view.id,
|
||||||
fields,
|
fields,
|
||||||
primary,
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -596,13 +565,11 @@ class BaseBufferedRowView extends ViewType {
|
||||||
{ store },
|
{ store },
|
||||||
view,
|
view,
|
||||||
fields,
|
fields,
|
||||||
primary,
|
|
||||||
storePrefix = '',
|
storePrefix = '',
|
||||||
includeFieldOptions = false
|
includeFieldOptions = false
|
||||||
) {
|
) {
|
||||||
await store.dispatch(storePrefix + 'view/' + this.getType() + '/refresh', {
|
await store.dispatch(storePrefix + 'view/' + this.getType() + '/refresh', {
|
||||||
fields,
|
fields,
|
||||||
primary,
|
|
||||||
includeFieldOptions,
|
includeFieldOptions,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -679,7 +646,6 @@ class BaseBufferedRowView extends ViewType {
|
||||||
{ store },
|
{ store },
|
||||||
tableId,
|
tableId,
|
||||||
fields,
|
fields,
|
||||||
primary,
|
|
||||||
values,
|
values,
|
||||||
metadata,
|
metadata,
|
||||||
storePrefix = ''
|
storePrefix = ''
|
||||||
|
@ -690,7 +656,6 @@ class BaseBufferedRowView extends ViewType {
|
||||||
{
|
{
|
||||||
view: store.getters['view/getSelected'],
|
view: store.getters['view/getSelected'],
|
||||||
fields,
|
fields,
|
||||||
primary,
|
|
||||||
values,
|
values,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
@ -701,7 +666,6 @@ class BaseBufferedRowView extends ViewType {
|
||||||
{ store },
|
{ store },
|
||||||
tableId,
|
tableId,
|
||||||
fields,
|
fields,
|
||||||
primary,
|
|
||||||
row,
|
row,
|
||||||
values,
|
values,
|
||||||
metadata,
|
metadata,
|
||||||
|
@ -713,7 +677,6 @@ class BaseBufferedRowView extends ViewType {
|
||||||
{
|
{
|
||||||
view: store.getters['view/getSelected'],
|
view: store.getters['view/getSelected'],
|
||||||
fields,
|
fields,
|
||||||
primary,
|
|
||||||
row,
|
row,
|
||||||
values,
|
values,
|
||||||
}
|
}
|
||||||
|
@ -721,14 +684,13 @@ class BaseBufferedRowView extends ViewType {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async rowDeleted({ store }, tableId, fields, primary, row, storePrefix = '') {
|
async rowDeleted({ store }, tableId, fields, row, storePrefix = '') {
|
||||||
if (this.isCurrentView(store, tableId)) {
|
if (this.isCurrentView(store, tableId)) {
|
||||||
await store.dispatch(
|
await store.dispatch(
|
||||||
storePrefix + 'view/' + this.getType() + '/afterExistingRowDeleted',
|
storePrefix + 'view/' + this.getType() + '/afterExistingRowDeleted',
|
||||||
{
|
{
|
||||||
view: store.getters['view/getSelected'],
|
view: store.getters['view/getSelected'],
|
||||||
fields,
|
fields,
|
||||||
primary,
|
|
||||||
row,
|
row,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
@ -797,7 +759,6 @@ export class GalleryViewType extends BaseBufferedRowView {
|
||||||
storePrefix + 'view/gallery/updateSearch',
|
storePrefix + 'view/gallery/updateSearch',
|
||||||
{
|
{
|
||||||
fields: rootGetters['field/getAll'],
|
fields: rootGetters['field/getAll'],
|
||||||
primary: rootGetters['field/getPrimary'],
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
root: true,
|
root: true,
|
||||||
|
@ -871,7 +832,6 @@ export class FormViewType extends ViewType {
|
||||||
{ store },
|
{ store },
|
||||||
view,
|
view,
|
||||||
fields,
|
fields,
|
||||||
primary,
|
|
||||||
storePrefix = '',
|
storePrefix = '',
|
||||||
includeFieldOptions = false
|
includeFieldOptions = false
|
||||||
) {
|
) {
|
||||||
|
@ -913,7 +873,7 @@ export class FormViewType extends ViewType {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
async fetch({ store }, view, fields, primary, storePrefix = '') {
|
async fetch({ store }, view, fields, storePrefix = '') {
|
||||||
await store.dispatch(storePrefix + 'view/form/fetchInitial', {
|
await store.dispatch(storePrefix + 'view/form/fetchInitial', {
|
||||||
formId: view.id,
|
formId: view.id,
|
||||||
})
|
})
|
||||||
|
|
|
@ -135,7 +135,6 @@ exports[`ViewFilterForm component Full view filter component 1`] = `
|
||||||
<!---->
|
<!---->
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
<li
|
<li
|
||||||
class="select__item"
|
class="select__item"
|
||||||
>
|
>
|
||||||
|
@ -502,7 +501,6 @@ exports[`ViewFilterForm component Full view filter component 1`] = `
|
||||||
<!---->
|
<!---->
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
<li
|
<li
|
||||||
class="select__item active"
|
class="select__item active"
|
||||||
>
|
>
|
||||||
|
@ -805,7 +803,6 @@ exports[`ViewFilterForm component Test rating filter 1`] = `
|
||||||
<!---->
|
<!---->
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
<li
|
<li
|
||||||
class="select__item active"
|
class="select__item active"
|
||||||
>
|
>
|
||||||
|
@ -1108,7 +1105,6 @@ exports[`ViewFilterForm component Test rating filter 2`] = `
|
||||||
<!---->
|
<!---->
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
<li
|
<li
|
||||||
class="select__item active"
|
class="select__item active"
|
||||||
>
|
>
|
||||||
|
|
|
@ -127,22 +127,20 @@ describe('GalleryView component with decoration', () => {
|
||||||
})
|
})
|
||||||
mockServer.createFields(application, table, fieldData)
|
mockServer.createFields(application, table, fieldData)
|
||||||
await store.dispatch('field/fetchAll', table)
|
await store.dispatch('field/fetchAll', table)
|
||||||
const primary = store.getters['field/getPrimary']
|
|
||||||
const fields = store.getters['field/getAll']
|
const fields = store.getters['field/getAll']
|
||||||
|
|
||||||
mockServer.createGalleryRows(view, fields, rows)
|
mockServer.createGalleryRows(view, fields, rows)
|
||||||
await store.dispatch('page/view/gallery/fetchInitial', {
|
await store.dispatch('page/view/gallery/fetchInitial', {
|
||||||
viewId: 1,
|
viewId: 1,
|
||||||
fields,
|
fields,
|
||||||
primary,
|
|
||||||
})
|
})
|
||||||
await store.dispatch('view/fetchAll', { id: 1 })
|
await store.dispatch('view/fetchAll', { id: 1 })
|
||||||
|
|
||||||
return { application, table, primary, fields, view }
|
return { application, table, fields, view }
|
||||||
}
|
}
|
||||||
|
|
||||||
test('Default component with first_cell decoration', async () => {
|
test('Default component with first_cell decoration', async () => {
|
||||||
const { application, table, primary, fields, view } = await populateStore([
|
const { application, table, fields, view } = await populateStore([
|
||||||
{
|
{
|
||||||
type: 'fake_decorator',
|
type: 'fake_decorator',
|
||||||
value_provider_type: 'fake_value_provider_type',
|
value_provider_type: 'fake_value_provider_type',
|
||||||
|
@ -165,7 +163,6 @@ describe('GalleryView component with decoration', () => {
|
||||||
database: application,
|
database: application,
|
||||||
table,
|
table,
|
||||||
view,
|
view,
|
||||||
primary,
|
|
||||||
fields,
|
fields,
|
||||||
readOnly: false,
|
readOnly: false,
|
||||||
storePrefix: 'page/',
|
storePrefix: 'page/',
|
||||||
|
@ -175,7 +172,7 @@ describe('GalleryView component with decoration', () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
test('Default component with row wrapper decoration', async () => {
|
test('Default component with row wrapper decoration', async () => {
|
||||||
const { application, table, primary, fields, view } = await populateStore([
|
const { application, table, fields, view } = await populateStore([
|
||||||
{
|
{
|
||||||
type: 'fake_decorator',
|
type: 'fake_decorator',
|
||||||
value_provider_type: 'fake_value_provider_type',
|
value_provider_type: 'fake_value_provider_type',
|
||||||
|
@ -214,7 +211,6 @@ describe('GalleryView component with decoration', () => {
|
||||||
database: application,
|
database: application,
|
||||||
table,
|
table,
|
||||||
view,
|
view,
|
||||||
primary,
|
|
||||||
fields,
|
fields,
|
||||||
readOnly: false,
|
readOnly: false,
|
||||||
storePrefix: 'page/',
|
storePrefix: 'page/',
|
||||||
|
@ -224,7 +220,7 @@ describe('GalleryView component with decoration', () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
test('Default component with unavailable decoration', async () => {
|
test('Default component with unavailable decoration', async () => {
|
||||||
const { application, table, primary, fields, view } = await populateStore([
|
const { application, table, fields, view } = await populateStore([
|
||||||
{
|
{
|
||||||
type: 'fake_decorator',
|
type: 'fake_decorator',
|
||||||
value_provider_type: 'fake_value_provider_type',
|
value_provider_type: 'fake_value_provider_type',
|
||||||
|
@ -244,7 +240,6 @@ describe('GalleryView component with decoration', () => {
|
||||||
database: application,
|
database: application,
|
||||||
table,
|
table,
|
||||||
view,
|
view,
|
||||||
primary,
|
|
||||||
fields,
|
fields,
|
||||||
readOnly: false,
|
readOnly: false,
|
||||||
storePrefix: 'page/',
|
storePrefix: 'page/',
|
||||||
|
|
|
@ -137,11 +137,11 @@ describe('GridView component with decoration', () => {
|
||||||
primary,
|
primary,
|
||||||
})
|
})
|
||||||
await store.dispatch('view/fetchAll', { id: 1 })
|
await store.dispatch('view/fetchAll', { id: 1 })
|
||||||
return { application, table, primary, fields, view }
|
return { application, table, fields, view }
|
||||||
}
|
}
|
||||||
|
|
||||||
test('Default component with first_cell decoration', async () => {
|
test('Default component with first_cell decoration', async () => {
|
||||||
const { application, table, primary, fields, view } = await populateStore([
|
const { application, table, fields, view } = await populateStore([
|
||||||
{
|
{
|
||||||
type: 'fake_decorator',
|
type: 'fake_decorator',
|
||||||
value_provider_type: 'fake_value_provider_type',
|
value_provider_type: 'fake_value_provider_type',
|
||||||
|
@ -164,7 +164,6 @@ describe('GridView component with decoration', () => {
|
||||||
database: application,
|
database: application,
|
||||||
table,
|
table,
|
||||||
view,
|
view,
|
||||||
primary,
|
|
||||||
fields,
|
fields,
|
||||||
readOnly: false,
|
readOnly: false,
|
||||||
storePrefix: 'page/',
|
storePrefix: 'page/',
|
||||||
|
@ -174,7 +173,7 @@ describe('GridView component with decoration', () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
test('Default component with row wrapper decoration', async () => {
|
test('Default component with row wrapper decoration', async () => {
|
||||||
const { application, table, primary, fields, view } = await populateStore([
|
const { application, table, fields, view } = await populateStore([
|
||||||
{
|
{
|
||||||
type: 'fake_decorator',
|
type: 'fake_decorator',
|
||||||
value_provider_type: 'fake_value_provider_type',
|
value_provider_type: 'fake_value_provider_type',
|
||||||
|
@ -213,7 +212,6 @@ describe('GridView component with decoration', () => {
|
||||||
database: application,
|
database: application,
|
||||||
table,
|
table,
|
||||||
view,
|
view,
|
||||||
primary,
|
|
||||||
fields,
|
fields,
|
||||||
readOnly: false,
|
readOnly: false,
|
||||||
storePrefix: 'page/',
|
storePrefix: 'page/',
|
||||||
|
@ -223,7 +221,7 @@ describe('GridView component with decoration', () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
test('Default component with unavailable decoration', async () => {
|
test('Default component with unavailable decoration', async () => {
|
||||||
const { application, table, primary, fields, view } = await populateStore([
|
const { application, table, fields, view } = await populateStore([
|
||||||
{
|
{
|
||||||
type: 'fake_decorator',
|
type: 'fake_decorator',
|
||||||
value_provider_type: 'fake_value_provider_type',
|
value_provider_type: 'fake_value_provider_type',
|
||||||
|
@ -243,7 +241,6 @@ describe('GridView component with decoration', () => {
|
||||||
database: application,
|
database: application,
|
||||||
table,
|
table,
|
||||||
view,
|
view,
|
||||||
primary,
|
|
||||||
fields,
|
fields,
|
||||||
readOnly: false,
|
readOnly: false,
|
||||||
storePrefix: 'page/',
|
storePrefix: 'page/',
|
||||||
|
|
|
@ -163,7 +163,7 @@ describe('GridViewRows component with decoration', () => {
|
||||||
primary,
|
primary,
|
||||||
})
|
})
|
||||||
await store.dispatch('view/fetchAll', { id: table.id })
|
await store.dispatch('view/fetchAll', { id: table.id })
|
||||||
return { application, table, primary, fields, view }
|
return { application, table, fields, view }
|
||||||
}
|
}
|
||||||
|
|
||||||
const mountComponent = async (props) => {
|
const mountComponent = async (props) => {
|
||||||
|
@ -181,7 +181,7 @@ describe('GridViewRows component with decoration', () => {
|
||||||
}
|
}
|
||||||
|
|
||||||
test('Default component', async () => {
|
test('Default component', async () => {
|
||||||
const { application, table, primary, fields, view } = await populateStore()
|
const { application, table, fields, view } = await populateStore()
|
||||||
|
|
||||||
const fakeDecorator = new FakeDecoratorType({ app: testApp })
|
const fakeDecorator = new FakeDecoratorType({ app: testApp })
|
||||||
const fakeValueProvider = new FakeValueProviderType({ app: testApp })
|
const fakeValueProvider = new FakeValueProviderType({ app: testApp })
|
||||||
|
@ -193,7 +193,6 @@ describe('GridViewRows component with decoration', () => {
|
||||||
database: application,
|
database: application,
|
||||||
view,
|
view,
|
||||||
table,
|
table,
|
||||||
primary,
|
|
||||||
fields,
|
fields,
|
||||||
readOnly: false,
|
readOnly: false,
|
||||||
})
|
})
|
||||||
|
@ -202,7 +201,7 @@ describe('GridViewRows component with decoration', () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
test('View with decoration configured', async () => {
|
test('View with decoration configured', async () => {
|
||||||
const { application, table, primary, fields, view } = await populateStore({
|
const { application, table, fields, view } = await populateStore({
|
||||||
decorations: [
|
decorations: [
|
||||||
{
|
{
|
||||||
type: 'fake_decorator',
|
type: 'fake_decorator',
|
||||||
|
@ -229,7 +228,6 @@ describe('GridViewRows component with decoration', () => {
|
||||||
database: application,
|
database: application,
|
||||||
view,
|
view,
|
||||||
table,
|
table,
|
||||||
primary,
|
|
||||||
fields,
|
fields,
|
||||||
readOnly: false,
|
readOnly: false,
|
||||||
})
|
})
|
||||||
|
@ -238,7 +236,7 @@ describe('GridViewRows component with decoration', () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
test('Should show unavailable decorator tooltip', async () => {
|
test('Should show unavailable decorator tooltip', async () => {
|
||||||
const { application, table, primary, fields, view } = await populateStore()
|
const { application, table, fields, view } = await populateStore()
|
||||||
|
|
||||||
const fakeDecorator = new FakeDecoratorType({ app: testApp })
|
const fakeDecorator = new FakeDecoratorType({ app: testApp })
|
||||||
const fakeValueProvider = new FakeValueProviderType({ app: testApp })
|
const fakeValueProvider = new FakeValueProviderType({ app: testApp })
|
||||||
|
@ -252,7 +250,6 @@ describe('GridViewRows component with decoration', () => {
|
||||||
database: application,
|
database: application,
|
||||||
view,
|
view,
|
||||||
table,
|
table,
|
||||||
primary,
|
|
||||||
fields,
|
fields,
|
||||||
readOnly: false,
|
readOnly: false,
|
||||||
})
|
})
|
||||||
|
@ -265,7 +262,7 @@ describe('GridViewRows component with decoration', () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
test('Should show cant add decorator tooltip', async () => {
|
test('Should show cant add decorator tooltip', async () => {
|
||||||
const { application, table, primary, fields, view } = await populateStore()
|
const { application, table, fields, view } = await populateStore()
|
||||||
|
|
||||||
const fakeDecorator = new FakeDecoratorType({ app: testApp })
|
const fakeDecorator = new FakeDecoratorType({ app: testApp })
|
||||||
const fakeValueProvider = new FakeValueProviderType({ app: testApp })
|
const fakeValueProvider = new FakeValueProviderType({ app: testApp })
|
||||||
|
@ -279,7 +276,6 @@ describe('GridViewRows component with decoration', () => {
|
||||||
database: application,
|
database: application,
|
||||||
view,
|
view,
|
||||||
table,
|
table,
|
||||||
primary,
|
|
||||||
fields,
|
fields,
|
||||||
readOnly: false,
|
readOnly: false,
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,19 +1,18 @@
|
||||||
import { TestApp } from '@baserow/test/helpers/testApp'
|
import { TestApp } from '@baserow/test/helpers/testApp'
|
||||||
import ViewFilterForm from '@baserow/modules/database/components/view/ViewFilterForm'
|
import ViewFilterForm from '@baserow/modules/database/components/view/ViewFilterForm'
|
||||||
|
|
||||||
const primary = {
|
|
||||||
id: 1,
|
|
||||||
name: 'Name',
|
|
||||||
order: 0,
|
|
||||||
type: 'text',
|
|
||||||
primary: true,
|
|
||||||
text_default: '',
|
|
||||||
_: {
|
|
||||||
loading: false,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
const fields = [
|
const fields = [
|
||||||
|
{
|
||||||
|
id: 1,
|
||||||
|
name: 'Name',
|
||||||
|
order: 0,
|
||||||
|
type: 'text',
|
||||||
|
primary: true,
|
||||||
|
text_default: '',
|
||||||
|
_: {
|
||||||
|
loading: false,
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
id: 2,
|
id: 2,
|
||||||
table_id: 196,
|
table_id: 196,
|
||||||
|
@ -91,7 +90,6 @@ describe('ViewFilterForm component', () => {
|
||||||
|
|
||||||
const mountViewFilterForm = async (
|
const mountViewFilterForm = async (
|
||||||
props = {
|
props = {
|
||||||
primary: {},
|
|
||||||
fields: [],
|
fields: [],
|
||||||
view: { filters: [], _: {} },
|
view: { filters: [], _: {} },
|
||||||
readOnly: false,
|
readOnly: false,
|
||||||
|
@ -112,7 +110,6 @@ describe('ViewFilterForm component', () => {
|
||||||
|
|
||||||
test('Full view filter component', async () => {
|
test('Full view filter component', async () => {
|
||||||
const wrapper = await mountViewFilterForm({
|
const wrapper = await mountViewFilterForm({
|
||||||
primary,
|
|
||||||
fields,
|
fields,
|
||||||
view,
|
view,
|
||||||
readOnly: false,
|
readOnly: false,
|
||||||
|
@ -150,7 +147,6 @@ describe('ViewFilterForm component', () => {
|
||||||
// Mounting the component
|
// Mounting the component
|
||||||
const wrapper = await mountViewFilterForm(
|
const wrapper = await mountViewFilterForm(
|
||||||
{
|
{
|
||||||
primary,
|
|
||||||
fields,
|
fields,
|
||||||
view: viewClone,
|
view: viewClone,
|
||||||
readOnly: false,
|
readOnly: false,
|
||||||
|
|
|
@ -373,13 +373,14 @@ describe('Buffered rows view store helper', () => {
|
||||||
filters: [],
|
filters: [],
|
||||||
sortings: [],
|
sortings: [],
|
||||||
}
|
}
|
||||||
const fields = []
|
const fields = [
|
||||||
const primary = {
|
{
|
||||||
id: 1,
|
id: 1,
|
||||||
name: 'Test 1',
|
name: 'Test 1',
|
||||||
type: 'text',
|
type: 'text',
|
||||||
primary: true,
|
primary: true,
|
||||||
}
|
},
|
||||||
|
]
|
||||||
const populateRow = (row) => {
|
const populateRow = (row) => {
|
||||||
row._ = {}
|
row._ = {}
|
||||||
return row
|
return row
|
||||||
|
@ -414,7 +415,6 @@ describe('Buffered rows view store helper', () => {
|
||||||
let index = await store.dispatch('test/findIndexOfNotExistingRow', {
|
let index = await store.dispatch('test/findIndexOfNotExistingRow', {
|
||||||
view,
|
view,
|
||||||
fields,
|
fields,
|
||||||
primary,
|
|
||||||
row: {
|
row: {
|
||||||
id: 0,
|
id: 0,
|
||||||
order: '0.00000000000000000000',
|
order: '0.00000000000000000000',
|
||||||
|
@ -426,7 +426,6 @@ describe('Buffered rows view store helper', () => {
|
||||||
index = await store.dispatch('test/findIndexOfNotExistingRow', {
|
index = await store.dispatch('test/findIndexOfNotExistingRow', {
|
||||||
view,
|
view,
|
||||||
fields,
|
fields,
|
||||||
primary,
|
|
||||||
row: {
|
row: {
|
||||||
id: 5,
|
id: 5,
|
||||||
order: '3.50000000000000000000',
|
order: '3.50000000000000000000',
|
||||||
|
@ -438,7 +437,6 @@ describe('Buffered rows view store helper', () => {
|
||||||
index = await store.dispatch('test/findIndexOfNotExistingRow', {
|
index = await store.dispatch('test/findIndexOfNotExistingRow', {
|
||||||
view,
|
view,
|
||||||
fields,
|
fields,
|
||||||
primary,
|
|
||||||
row: {
|
row: {
|
||||||
id: 5,
|
id: 5,
|
||||||
order: '5.00000000000000000000',
|
order: '5.00000000000000000000',
|
||||||
|
@ -450,7 +448,6 @@ describe('Buffered rows view store helper', () => {
|
||||||
index = await store.dispatch('test/findIndexOfNotExistingRow', {
|
index = await store.dispatch('test/findIndexOfNotExistingRow', {
|
||||||
view,
|
view,
|
||||||
fields,
|
fields,
|
||||||
primary,
|
|
||||||
row: {
|
row: {
|
||||||
id: 13,
|
id: 13,
|
||||||
order: '13.50000000000000000000',
|
order: '13.50000000000000000000',
|
||||||
|
@ -462,7 +459,6 @@ describe('Buffered rows view store helper', () => {
|
||||||
index = await store.dispatch('test/findIndexOfNotExistingRow', {
|
index = await store.dispatch('test/findIndexOfNotExistingRow', {
|
||||||
view,
|
view,
|
||||||
fields,
|
fields,
|
||||||
primary,
|
|
||||||
row: {
|
row: {
|
||||||
id: 100,
|
id: 100,
|
||||||
order: '100.00000000000000000000',
|
order: '100.00000000000000000000',
|
||||||
|
@ -480,13 +476,14 @@ describe('Buffered rows view store helper', () => {
|
||||||
filters: [],
|
filters: [],
|
||||||
sortings: [],
|
sortings: [],
|
||||||
}
|
}
|
||||||
const fields = []
|
const fields = [
|
||||||
const primary = {
|
{
|
||||||
id: 1,
|
id: 1,
|
||||||
name: 'Test 1',
|
name: 'Test 1',
|
||||||
type: 'text',
|
type: 'text',
|
||||||
primary: true,
|
primary: true,
|
||||||
}
|
},
|
||||||
|
]
|
||||||
const populateRow = (row) => {
|
const populateRow = (row) => {
|
||||||
row._ = {}
|
row._ = {}
|
||||||
return row
|
return row
|
||||||
|
@ -523,7 +520,6 @@ describe('Buffered rows view store helper', () => {
|
||||||
let index = await store.dispatch('test/findIndexOfNotExistingRow', {
|
let index = await store.dispatch('test/findIndexOfNotExistingRow', {
|
||||||
view,
|
view,
|
||||||
fields,
|
fields,
|
||||||
primary,
|
|
||||||
row: {
|
row: {
|
||||||
id: 4,
|
id: 4,
|
||||||
order: '4.00000000000000000000',
|
order: '4.00000000000000000000',
|
||||||
|
@ -535,7 +531,6 @@ describe('Buffered rows view store helper', () => {
|
||||||
index = await store.dispatch('test/findIndexOfNotExistingRow', {
|
index = await store.dispatch('test/findIndexOfNotExistingRow', {
|
||||||
view,
|
view,
|
||||||
fields,
|
fields,
|
||||||
primary,
|
|
||||||
row: {
|
row: {
|
||||||
id: 2,
|
id: 2,
|
||||||
order: '2.00000000000000000000',
|
order: '2.00000000000000000000',
|
||||||
|
@ -547,7 +542,6 @@ describe('Buffered rows view store helper', () => {
|
||||||
index = await store.dispatch('test/findIndexOfNotExistingRow', {
|
index = await store.dispatch('test/findIndexOfNotExistingRow', {
|
||||||
view,
|
view,
|
||||||
fields,
|
fields,
|
||||||
primary,
|
|
||||||
row: {
|
row: {
|
||||||
id: 13,
|
id: 13,
|
||||||
order: '13.00000000000000000000',
|
order: '13.00000000000000000000',
|
||||||
|
@ -559,7 +553,6 @@ describe('Buffered rows view store helper', () => {
|
||||||
index = await store.dispatch('test/findIndexOfNotExistingRow', {
|
index = await store.dispatch('test/findIndexOfNotExistingRow', {
|
||||||
view,
|
view,
|
||||||
fields,
|
fields,
|
||||||
primary,
|
|
||||||
row: {
|
row: {
|
||||||
id: 100,
|
id: 100,
|
||||||
order: '100.00000000000000000000',
|
order: '100.00000000000000000000',
|
||||||
|
@ -577,13 +570,14 @@ describe('Buffered rows view store helper', () => {
|
||||||
filters: [],
|
filters: [],
|
||||||
sortings: [],
|
sortings: [],
|
||||||
}
|
}
|
||||||
const fields = []
|
const fields = [
|
||||||
const primary = {
|
{
|
||||||
id: 1,
|
id: 1,
|
||||||
name: 'Test 1',
|
name: 'Test 1',
|
||||||
type: 'text',
|
type: 'text',
|
||||||
primary: true,
|
primary: true,
|
||||||
}
|
},
|
||||||
|
]
|
||||||
const populateRow = (row) => {
|
const populateRow = (row) => {
|
||||||
row._ = {}
|
row._ = {}
|
||||||
return row
|
return row
|
||||||
|
@ -618,7 +612,6 @@ describe('Buffered rows view store helper', () => {
|
||||||
let index = await store.dispatch('test/findIndexOfExistingRow', {
|
let index = await store.dispatch('test/findIndexOfExistingRow', {
|
||||||
view,
|
view,
|
||||||
fields,
|
fields,
|
||||||
primary,
|
|
||||||
row: {
|
row: {
|
||||||
id: 1,
|
id: 1,
|
||||||
order: '1.00000000000000000000',
|
order: '1.00000000000000000000',
|
||||||
|
@ -630,7 +623,6 @@ describe('Buffered rows view store helper', () => {
|
||||||
index = await store.dispatch('test/findIndexOfExistingRow', {
|
index = await store.dispatch('test/findIndexOfExistingRow', {
|
||||||
view,
|
view,
|
||||||
fields,
|
fields,
|
||||||
primary,
|
|
||||||
row: {
|
row: {
|
||||||
id: 3,
|
id: 3,
|
||||||
order: '3.00000000000000000000',
|
order: '3.00000000000000000000',
|
||||||
|
@ -642,7 +634,6 @@ describe('Buffered rows view store helper', () => {
|
||||||
index = await store.dispatch('test/findIndexOfExistingRow', {
|
index = await store.dispatch('test/findIndexOfExistingRow', {
|
||||||
view,
|
view,
|
||||||
fields,
|
fields,
|
||||||
primary,
|
|
||||||
row: {
|
row: {
|
||||||
id: 4,
|
id: 4,
|
||||||
order: '4.00000000000000000000',
|
order: '4.00000000000000000000',
|
||||||
|
@ -654,7 +645,6 @@ describe('Buffered rows view store helper', () => {
|
||||||
index = await store.dispatch('test/findIndexOfExistingRow', {
|
index = await store.dispatch('test/findIndexOfExistingRow', {
|
||||||
view,
|
view,
|
||||||
fields,
|
fields,
|
||||||
primary,
|
|
||||||
row: {
|
row: {
|
||||||
id: 5,
|
id: 5,
|
||||||
order: '5.00000000000000000000',
|
order: '5.00000000000000000000',
|
||||||
|
@ -666,7 +656,6 @@ describe('Buffered rows view store helper', () => {
|
||||||
index = await store.dispatch('test/findIndexOfExistingRow', {
|
index = await store.dispatch('test/findIndexOfExistingRow', {
|
||||||
view,
|
view,
|
||||||
fields,
|
fields,
|
||||||
primary,
|
|
||||||
row: {
|
row: {
|
||||||
id: 10,
|
id: 10,
|
||||||
order: '10.00000000000000000000',
|
order: '10.00000000000000000000',
|
||||||
|
@ -678,7 +667,6 @@ describe('Buffered rows view store helper', () => {
|
||||||
index = await store.dispatch('test/findIndexOfExistingRow', {
|
index = await store.dispatch('test/findIndexOfExistingRow', {
|
||||||
view,
|
view,
|
||||||
fields,
|
fields,
|
||||||
primary,
|
|
||||||
row: {
|
row: {
|
||||||
id: 14,
|
id: 14,
|
||||||
order: '14.00000000000000000000',
|
order: '14.00000000000000000000',
|
||||||
|
@ -690,7 +678,6 @@ describe('Buffered rows view store helper', () => {
|
||||||
index = await store.dispatch('test/findIndexOfExistingRow', {
|
index = await store.dispatch('test/findIndexOfExistingRow', {
|
||||||
view,
|
view,
|
||||||
fields,
|
fields,
|
||||||
primary,
|
|
||||||
row: {
|
row: {
|
||||||
id: 15,
|
id: 15,
|
||||||
order: '15.00000000000000000000',
|
order: '15.00000000000000000000',
|
||||||
|
@ -709,13 +696,14 @@ describe('Buffered rows view store helper', () => {
|
||||||
filters: [],
|
filters: [],
|
||||||
sortings: [],
|
sortings: [],
|
||||||
}
|
}
|
||||||
const fields = []
|
const fields = [
|
||||||
const primary = {
|
{
|
||||||
id: 1,
|
id: 1,
|
||||||
name: 'Test 1',
|
name: 'Test 1',
|
||||||
type: 'text',
|
type: 'text',
|
||||||
primary: true,
|
primary: true,
|
||||||
}
|
},
|
||||||
|
]
|
||||||
const populateRow = (row) => {
|
const populateRow = (row) => {
|
||||||
row._ = {}
|
row._ = {}
|
||||||
return row
|
return row
|
||||||
|
@ -752,7 +740,6 @@ describe('Buffered rows view store helper', () => {
|
||||||
let index = await store.dispatch('test/findIndexOfExistingRow', {
|
let index = await store.dispatch('test/findIndexOfExistingRow', {
|
||||||
view,
|
view,
|
||||||
fields,
|
fields,
|
||||||
primary,
|
|
||||||
row: {
|
row: {
|
||||||
id: 1,
|
id: 1,
|
||||||
order: '1.00000000000000000000',
|
order: '1.00000000000000000000',
|
||||||
|
@ -764,7 +751,6 @@ describe('Buffered rows view store helper', () => {
|
||||||
index = await store.dispatch('test/findIndexOfExistingRow', {
|
index = await store.dispatch('test/findIndexOfExistingRow', {
|
||||||
view,
|
view,
|
||||||
fields,
|
fields,
|
||||||
primary,
|
|
||||||
row: {
|
row: {
|
||||||
id: 0,
|
id: 0,
|
||||||
order: '0.00000000000000000000',
|
order: '0.00000000000000000000',
|
||||||
|
@ -776,7 +762,6 @@ describe('Buffered rows view store helper', () => {
|
||||||
index = await store.dispatch('test/findIndexOfExistingRow', {
|
index = await store.dispatch('test/findIndexOfExistingRow', {
|
||||||
view,
|
view,
|
||||||
fields,
|
fields,
|
||||||
primary,
|
|
||||||
row: {
|
row: {
|
||||||
id: 4,
|
id: 4,
|
||||||
order: '4.00000000000000000000',
|
order: '4.00000000000000000000',
|
||||||
|
@ -788,7 +773,6 @@ describe('Buffered rows view store helper', () => {
|
||||||
index = await store.dispatch('test/findIndexOfExistingRow', {
|
index = await store.dispatch('test/findIndexOfExistingRow', {
|
||||||
view,
|
view,
|
||||||
fields,
|
fields,
|
||||||
primary,
|
|
||||||
row: {
|
row: {
|
||||||
id: 6,
|
id: 6,
|
||||||
order: '6.00000000000000000000',
|
order: '6.00000000000000000000',
|
||||||
|
@ -800,7 +784,6 @@ describe('Buffered rows view store helper', () => {
|
||||||
index = await store.dispatch('test/findIndexOfExistingRow', {
|
index = await store.dispatch('test/findIndexOfExistingRow', {
|
||||||
view,
|
view,
|
||||||
fields,
|
fields,
|
||||||
primary,
|
|
||||||
row: {
|
row: {
|
||||||
id: 12,
|
id: 12,
|
||||||
order: '12.00000000000000000000',
|
order: '12.00000000000000000000',
|
||||||
|
@ -812,7 +795,6 @@ describe('Buffered rows view store helper', () => {
|
||||||
index = await store.dispatch('test/findIndexOfExistingRow', {
|
index = await store.dispatch('test/findIndexOfExistingRow', {
|
||||||
view,
|
view,
|
||||||
fields,
|
fields,
|
||||||
primary,
|
|
||||||
row: {
|
row: {
|
||||||
id: 15,
|
id: 15,
|
||||||
order: '15.00000000000000000000',
|
order: '15.00000000000000000000',
|
||||||
|
@ -838,13 +820,14 @@ describe('Buffered rows view store helper', () => {
|
||||||
],
|
],
|
||||||
sortings: [],
|
sortings: [],
|
||||||
}
|
}
|
||||||
const fields = []
|
const fields = [
|
||||||
const primary = {
|
{
|
||||||
id: 1,
|
id: 1,
|
||||||
name: 'Test 1',
|
name: 'Test 1',
|
||||||
type: 'text',
|
type: 'text',
|
||||||
primary: true,
|
primary: true,
|
||||||
}
|
},
|
||||||
|
]
|
||||||
|
|
||||||
const testStore = bufferedRows({ service: null, populateRow: null })
|
const testStore = bufferedRows({ service: null, populateRow: null })
|
||||||
store.registerModule('test', testStore)
|
store.registerModule('test', testStore)
|
||||||
|
@ -853,7 +836,6 @@ describe('Buffered rows view store helper', () => {
|
||||||
await store.dispatch('test/rowMatchesFilters', {
|
await store.dispatch('test/rowMatchesFilters', {
|
||||||
view,
|
view,
|
||||||
fields,
|
fields,
|
||||||
primary,
|
|
||||||
row: { id: 12, order: '12.00000000000000000000', field_1: 'Value 12' },
|
row: { id: 12, order: '12.00000000000000000000', field_1: 'Value 12' },
|
||||||
})
|
})
|
||||||
).toBe(true)
|
).toBe(true)
|
||||||
|
@ -861,7 +843,6 @@ describe('Buffered rows view store helper', () => {
|
||||||
await store.dispatch('test/rowMatchesFilters', {
|
await store.dispatch('test/rowMatchesFilters', {
|
||||||
view,
|
view,
|
||||||
fields,
|
fields,
|
||||||
primary,
|
|
||||||
row: {
|
row: {
|
||||||
id: 12,
|
id: 12,
|
||||||
order: '12.00000000000000000000',
|
order: '12.00000000000000000000',
|
||||||
|
@ -873,7 +854,6 @@ describe('Buffered rows view store helper', () => {
|
||||||
await store.dispatch('test/rowMatchesFilters', {
|
await store.dispatch('test/rowMatchesFilters', {
|
||||||
view,
|
view,
|
||||||
fields,
|
fields,
|
||||||
primary,
|
|
||||||
row: {
|
row: {
|
||||||
id: 12,
|
id: 12,
|
||||||
order: '12.00000000000000000000',
|
order: '12.00000000000000000000',
|
||||||
|
@ -887,7 +867,6 @@ describe('Buffered rows view store helper', () => {
|
||||||
await store.dispatch('test/rowMatchesFilters', {
|
await store.dispatch('test/rowMatchesFilters', {
|
||||||
view,
|
view,
|
||||||
fields,
|
fields,
|
||||||
primary,
|
|
||||||
row: {
|
row: {
|
||||||
id: 12,
|
id: 12,
|
||||||
order: '12.00000000000000000000',
|
order: '12.00000000000000000000',
|
||||||
|
@ -905,13 +884,14 @@ describe('Buffered rows view store helper', () => {
|
||||||
filters: [],
|
filters: [],
|
||||||
sortings: [],
|
sortings: [],
|
||||||
}
|
}
|
||||||
const fields = []
|
const fields = [
|
||||||
const primary = {
|
{
|
||||||
id: 1,
|
id: 1,
|
||||||
name: 'Test 1',
|
name: 'Test 1',
|
||||||
type: 'text',
|
type: 'text',
|
||||||
primary: true,
|
primary: true,
|
||||||
}
|
},
|
||||||
|
]
|
||||||
const populateRow = (row) => {
|
const populateRow = (row) => {
|
||||||
row._ = {}
|
row._ = {}
|
||||||
return row
|
return row
|
||||||
|
@ -945,7 +925,6 @@ describe('Buffered rows view store helper', () => {
|
||||||
await store.dispatch('test/afterNewRowCreated', {
|
await store.dispatch('test/afterNewRowCreated', {
|
||||||
view,
|
view,
|
||||||
fields,
|
fields,
|
||||||
primary,
|
|
||||||
values: {
|
values: {
|
||||||
id: 2,
|
id: 2,
|
||||||
order: '2.00000000000000000000',
|
order: '2.00000000000000000000',
|
||||||
|
@ -971,7 +950,6 @@ describe('Buffered rows view store helper', () => {
|
||||||
await store.dispatch('test/afterNewRowCreated', {
|
await store.dispatch('test/afterNewRowCreated', {
|
||||||
view,
|
view,
|
||||||
fields,
|
fields,
|
||||||
primary,
|
|
||||||
values: {
|
values: {
|
||||||
id: 4,
|
id: 4,
|
||||||
order: '4.00000000000000000000',
|
order: '4.00000000000000000000',
|
||||||
|
@ -998,7 +976,6 @@ describe('Buffered rows view store helper', () => {
|
||||||
await store.dispatch('test/afterNewRowCreated', {
|
await store.dispatch('test/afterNewRowCreated', {
|
||||||
view,
|
view,
|
||||||
fields,
|
fields,
|
||||||
primary,
|
|
||||||
values: {
|
values: {
|
||||||
id: 13,
|
id: 13,
|
||||||
order: '13.00000000000000000000',
|
order: '13.00000000000000000000',
|
||||||
|
@ -1025,7 +1002,6 @@ describe('Buffered rows view store helper', () => {
|
||||||
await store.dispatch('test/afterNewRowCreated', {
|
await store.dispatch('test/afterNewRowCreated', {
|
||||||
view,
|
view,
|
||||||
fields,
|
fields,
|
||||||
primary,
|
|
||||||
values: {
|
values: {
|
||||||
id: 16,
|
id: 16,
|
||||||
order: '16.00000000000000000000',
|
order: '16.00000000000000000000',
|
||||||
|
@ -1059,7 +1035,6 @@ describe('Buffered rows view store helper', () => {
|
||||||
await store.dispatch('test/afterNewRowCreated', {
|
await store.dispatch('test/afterNewRowCreated', {
|
||||||
view,
|
view,
|
||||||
fields,
|
fields,
|
||||||
primary,
|
|
||||||
values: {
|
values: {
|
||||||
id: 17,
|
id: 17,
|
||||||
order: '17.00000000000000000000',
|
order: '17.00000000000000000000',
|
||||||
|
@ -1093,7 +1068,6 @@ describe('Buffered rows view store helper', () => {
|
||||||
await store.dispatch('test/afterNewRowCreated', {
|
await store.dispatch('test/afterNewRowCreated', {
|
||||||
view,
|
view,
|
||||||
fields,
|
fields,
|
||||||
primary,
|
|
||||||
values: {
|
values: {
|
||||||
id: 0,
|
id: 0,
|
||||||
order: '0.00000000000000000000',
|
order: '0.00000000000000000000',
|
||||||
|
@ -1137,13 +1111,14 @@ describe('Buffered rows view store helper', () => {
|
||||||
],
|
],
|
||||||
sortings: [],
|
sortings: [],
|
||||||
}
|
}
|
||||||
const fields = []
|
const fields = [
|
||||||
const primary = {
|
{
|
||||||
id: 1,
|
id: 1,
|
||||||
name: 'Test 1',
|
name: 'Test 1',
|
||||||
type: 'text',
|
type: 'text',
|
||||||
primary: true,
|
primary: true,
|
||||||
}
|
},
|
||||||
|
]
|
||||||
const populateRow = (row) => {
|
const populateRow = (row) => {
|
||||||
row._ = {}
|
row._ = {}
|
||||||
return row
|
return row
|
||||||
|
@ -1177,7 +1152,6 @@ describe('Buffered rows view store helper', () => {
|
||||||
await store.dispatch('test/afterNewRowCreated', {
|
await store.dispatch('test/afterNewRowCreated', {
|
||||||
view,
|
view,
|
||||||
fields,
|
fields,
|
||||||
primary,
|
|
||||||
values: {
|
values: {
|
||||||
id: 4,
|
id: 4,
|
||||||
order: '4.00000000000000000000',
|
order: '4.00000000000000000000',
|
||||||
|
@ -1206,13 +1180,14 @@ describe('Buffered rows view store helper', () => {
|
||||||
filters: [],
|
filters: [],
|
||||||
sortings: [],
|
sortings: [],
|
||||||
}
|
}
|
||||||
const fields = []
|
const fields = [
|
||||||
const primary = {
|
{
|
||||||
id: 1,
|
id: 1,
|
||||||
name: 'Test 1',
|
name: 'Test 1',
|
||||||
type: 'text',
|
type: 'text',
|
||||||
primary: true,
|
primary: true,
|
||||||
}
|
},
|
||||||
|
]
|
||||||
const populateRow = (row) => {
|
const populateRow = (row) => {
|
||||||
row._ = {}
|
row._ = {}
|
||||||
return row
|
return row
|
||||||
|
@ -1252,7 +1227,6 @@ describe('Buffered rows view store helper', () => {
|
||||||
await store.dispatch('test/afterExistingRowUpdated', {
|
await store.dispatch('test/afterExistingRowUpdated', {
|
||||||
view,
|
view,
|
||||||
fields,
|
fields,
|
||||||
primary,
|
|
||||||
row: {
|
row: {
|
||||||
id: 5,
|
id: 5,
|
||||||
order: '5.00000000000000000000',
|
order: '5.00000000000000000000',
|
||||||
|
@ -1281,7 +1255,6 @@ describe('Buffered rows view store helper', () => {
|
||||||
await store.dispatch('test/afterExistingRowUpdated', {
|
await store.dispatch('test/afterExistingRowUpdated', {
|
||||||
view,
|
view,
|
||||||
fields,
|
fields,
|
||||||
primary,
|
|
||||||
row: {
|
row: {
|
||||||
id: 5,
|
id: 5,
|
||||||
order: '5.00000000000000000000',
|
order: '5.00000000000000000000',
|
||||||
|
@ -1308,7 +1281,6 @@ describe('Buffered rows view store helper', () => {
|
||||||
await store.dispatch('test/afterExistingRowUpdated', {
|
await store.dispatch('test/afterExistingRowUpdated', {
|
||||||
view,
|
view,
|
||||||
fields,
|
fields,
|
||||||
primary,
|
|
||||||
row: {
|
row: {
|
||||||
id: 5,
|
id: 5,
|
||||||
order: '6.50000000000000000000',
|
order: '6.50000000000000000000',
|
||||||
|
@ -1334,7 +1306,6 @@ describe('Buffered rows view store helper', () => {
|
||||||
await store.dispatch('test/afterExistingRowUpdated', {
|
await store.dispatch('test/afterExistingRowUpdated', {
|
||||||
view,
|
view,
|
||||||
fields,
|
fields,
|
||||||
primary,
|
|
||||||
row: {
|
row: {
|
||||||
id: 5,
|
id: 5,
|
||||||
order: '7.50000000000000000000',
|
order: '7.50000000000000000000',
|
||||||
|
@ -1374,13 +1345,14 @@ describe('Buffered rows view store helper', () => {
|
||||||
],
|
],
|
||||||
sortings: [],
|
sortings: [],
|
||||||
}
|
}
|
||||||
const fields = []
|
const fields = [
|
||||||
const primary = {
|
{
|
||||||
id: 1,
|
id: 1,
|
||||||
name: 'Test 1',
|
name: 'Test 1',
|
||||||
type: 'text',
|
type: 'text',
|
||||||
primary: true,
|
primary: true,
|
||||||
}
|
},
|
||||||
|
]
|
||||||
const populateRow = (row) => {
|
const populateRow = (row) => {
|
||||||
row._ = {}
|
row._ = {}
|
||||||
return row
|
return row
|
||||||
|
@ -1415,7 +1387,6 @@ describe('Buffered rows view store helper', () => {
|
||||||
await store.dispatch('test/afterExistingRowUpdated', {
|
await store.dispatch('test/afterExistingRowUpdated', {
|
||||||
view,
|
view,
|
||||||
fields,
|
fields,
|
||||||
primary,
|
|
||||||
row: {
|
row: {
|
||||||
id: 1,
|
id: 1,
|
||||||
order: '1.00000000000000000000',
|
order: '1.00000000000000000000',
|
||||||
|
@ -1443,7 +1414,6 @@ describe('Buffered rows view store helper', () => {
|
||||||
await store.dispatch('test/afterExistingRowUpdated', {
|
await store.dispatch('test/afterExistingRowUpdated', {
|
||||||
view,
|
view,
|
||||||
fields,
|
fields,
|
||||||
primary,
|
|
||||||
row: {
|
row: {
|
||||||
id: 4,
|
id: 4,
|
||||||
order: '4.00000000000000000000',
|
order: '4.00000000000000000000',
|
||||||
|
@ -1471,7 +1441,6 @@ describe('Buffered rows view store helper', () => {
|
||||||
await store.dispatch('test/afterExistingRowUpdated', {
|
await store.dispatch('test/afterExistingRowUpdated', {
|
||||||
view,
|
view,
|
||||||
fields,
|
fields,
|
||||||
primary,
|
|
||||||
row: {
|
row: {
|
||||||
id: 4,
|
id: 4,
|
||||||
order: '4.00000000000000000000',
|
order: '4.00000000000000000000',
|
||||||
|
@ -1498,7 +1467,6 @@ describe('Buffered rows view store helper', () => {
|
||||||
await store.dispatch('test/afterExistingRowUpdated', {
|
await store.dispatch('test/afterExistingRowUpdated', {
|
||||||
view,
|
view,
|
||||||
fields,
|
fields,
|
||||||
primary,
|
|
||||||
row: {
|
row: {
|
||||||
id: 15,
|
id: 15,
|
||||||
order: '15.00000000000000000000',
|
order: '15.00000000000000000000',
|
||||||
|
@ -1537,13 +1505,14 @@ describe('Buffered rows view store helper', () => {
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
const fields = []
|
const fields = [
|
||||||
const primary = {
|
{
|
||||||
id: 1,
|
id: 1,
|
||||||
name: 'Test 1',
|
name: 'Test 1',
|
||||||
type: 'text',
|
type: 'text',
|
||||||
primary: true,
|
primary: true,
|
||||||
}
|
},
|
||||||
|
]
|
||||||
const populateRow = (row) => {
|
const populateRow = (row) => {
|
||||||
row._ = {}
|
row._ = {}
|
||||||
return row
|
return row
|
||||||
|
@ -1570,7 +1539,6 @@ describe('Buffered rows view store helper', () => {
|
||||||
await store.dispatch('test/afterExistingRowUpdated', {
|
await store.dispatch('test/afterExistingRowUpdated', {
|
||||||
view,
|
view,
|
||||||
fields,
|
fields,
|
||||||
primary,
|
|
||||||
row: {
|
row: {
|
||||||
id: 3,
|
id: 3,
|
||||||
order: '3.00000000000000000000',
|
order: '3.00000000000000000000',
|
||||||
|
@ -1589,7 +1557,6 @@ describe('Buffered rows view store helper', () => {
|
||||||
await store.dispatch('test/afterExistingRowUpdated', {
|
await store.dispatch('test/afterExistingRowUpdated', {
|
||||||
view,
|
view,
|
||||||
fields,
|
fields,
|
||||||
primary,
|
|
||||||
row: {
|
row: {
|
||||||
id: 3,
|
id: 3,
|
||||||
order: '3.00000000000000000000',
|
order: '3.00000000000000000000',
|
||||||
|
@ -1607,7 +1574,6 @@ describe('Buffered rows view store helper', () => {
|
||||||
await store.dispatch('test/afterExistingRowUpdated', {
|
await store.dispatch('test/afterExistingRowUpdated', {
|
||||||
view,
|
view,
|
||||||
fields,
|
fields,
|
||||||
primary,
|
|
||||||
row: {
|
row: {
|
||||||
id: 3,
|
id: 3,
|
||||||
order: '3.00000000000000000000',
|
order: '3.00000000000000000000',
|
||||||
|
@ -1625,7 +1591,6 @@ describe('Buffered rows view store helper', () => {
|
||||||
await store.dispatch('test/afterExistingRowUpdated', {
|
await store.dispatch('test/afterExistingRowUpdated', {
|
||||||
view,
|
view,
|
||||||
fields,
|
fields,
|
||||||
primary,
|
|
||||||
row: {
|
row: {
|
||||||
id: 3,
|
id: 3,
|
||||||
order: '3.00000000000000000000',
|
order: '3.00000000000000000000',
|
||||||
|
@ -1643,7 +1608,6 @@ describe('Buffered rows view store helper', () => {
|
||||||
await store.dispatch('test/afterExistingRowUpdated', {
|
await store.dispatch('test/afterExistingRowUpdated', {
|
||||||
view,
|
view,
|
||||||
fields,
|
fields,
|
||||||
primary,
|
|
||||||
row: {
|
row: {
|
||||||
id: 3,
|
id: 3,
|
||||||
order: '3.00000000000000000000',
|
order: '3.00000000000000000000',
|
||||||
|
@ -1661,7 +1625,6 @@ describe('Buffered rows view store helper', () => {
|
||||||
await store.dispatch('test/afterExistingRowUpdated', {
|
await store.dispatch('test/afterExistingRowUpdated', {
|
||||||
view,
|
view,
|
||||||
fields,
|
fields,
|
||||||
primary,
|
|
||||||
row: {
|
row: {
|
||||||
id: 3,
|
id: 3,
|
||||||
order: '3.00000000000000000000',
|
order: '3.00000000000000000000',
|
||||||
|
@ -1679,7 +1642,6 @@ describe('Buffered rows view store helper', () => {
|
||||||
await store.dispatch('test/afterExistingRowUpdated', {
|
await store.dispatch('test/afterExistingRowUpdated', {
|
||||||
view,
|
view,
|
||||||
fields,
|
fields,
|
||||||
primary,
|
|
||||||
row: {
|
row: {
|
||||||
id: 3,
|
id: 3,
|
||||||
order: '3.00000000000000000000',
|
order: '3.00000000000000000000',
|
||||||
|
@ -1710,13 +1672,14 @@ describe('Buffered rows view store helper', () => {
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
const fields = []
|
const fields = [
|
||||||
const primary = {
|
{
|
||||||
id: 1,
|
id: 1,
|
||||||
name: 'Test 1',
|
name: 'Test 1',
|
||||||
type: 'text',
|
type: 'text',
|
||||||
primary: true,
|
primary: true,
|
||||||
}
|
},
|
||||||
|
]
|
||||||
const populateRow = (row) => {
|
const populateRow = (row) => {
|
||||||
row._ = {}
|
row._ = {}
|
||||||
return row
|
return row
|
||||||
|
@ -1747,7 +1710,6 @@ describe('Buffered rows view store helper', () => {
|
||||||
await store.dispatch('test/afterExistingRowUpdated', {
|
await store.dispatch('test/afterExistingRowUpdated', {
|
||||||
view,
|
view,
|
||||||
fields,
|
fields,
|
||||||
primary,
|
|
||||||
row: {
|
row: {
|
||||||
id: 7,
|
id: 7,
|
||||||
order: '7.00000000000000000000',
|
order: '7.00000000000000000000',
|
||||||
|
@ -1776,13 +1738,14 @@ describe('Buffered rows view store helper', () => {
|
||||||
filters: [],
|
filters: [],
|
||||||
sortings: [],
|
sortings: [],
|
||||||
}
|
}
|
||||||
const fields = []
|
const fields = [
|
||||||
const primary = {
|
{
|
||||||
id: 1,
|
id: 1,
|
||||||
name: 'Test 1',
|
name: 'Test 1',
|
||||||
type: 'text',
|
type: 'text',
|
||||||
primary: true,
|
primary: true,
|
||||||
}
|
},
|
||||||
|
]
|
||||||
const populateRow = (row) => {
|
const populateRow = (row) => {
|
||||||
row._ = {}
|
row._ = {}
|
||||||
return row
|
return row
|
||||||
|
@ -1817,7 +1780,6 @@ describe('Buffered rows view store helper', () => {
|
||||||
await store.dispatch('test/afterExistingRowDeleted', {
|
await store.dispatch('test/afterExistingRowDeleted', {
|
||||||
view,
|
view,
|
||||||
fields,
|
fields,
|
||||||
primary,
|
|
||||||
row: {
|
row: {
|
||||||
id: 1,
|
id: 1,
|
||||||
order: '1.00000000000000000000',
|
order: '1.00000000000000000000',
|
||||||
|
@ -1840,7 +1802,6 @@ describe('Buffered rows view store helper', () => {
|
||||||
await store.dispatch('test/afterExistingRowDeleted', {
|
await store.dispatch('test/afterExistingRowDeleted', {
|
||||||
view,
|
view,
|
||||||
fields,
|
fields,
|
||||||
primary,
|
|
||||||
row: {
|
row: {
|
||||||
id: 15,
|
id: 15,
|
||||||
order: '15.00000000000000000000',
|
order: '15.00000000000000000000',
|
||||||
|
@ -1861,7 +1822,6 @@ describe('Buffered rows view store helper', () => {
|
||||||
await store.dispatch('test/afterExistingRowDeleted', {
|
await store.dispatch('test/afterExistingRowDeleted', {
|
||||||
view,
|
view,
|
||||||
fields,
|
fields,
|
||||||
primary,
|
|
||||||
row: {
|
row: {
|
||||||
id: 9,
|
id: 9,
|
||||||
order: '9.00000000000000000000',
|
order: '9.00000000000000000000',
|
||||||
|
@ -1881,7 +1841,6 @@ describe('Buffered rows view store helper', () => {
|
||||||
await store.dispatch('test/afterExistingRowDeleted', {
|
await store.dispatch('test/afterExistingRowDeleted', {
|
||||||
view,
|
view,
|
||||||
fields,
|
fields,
|
||||||
primary,
|
|
||||||
row: {
|
row: {
|
||||||
id: 5,
|
id: 5,
|
||||||
order: '5.00000000000000000000',
|
order: '5.00000000000000000000',
|
||||||
|
@ -1900,7 +1859,6 @@ describe('Buffered rows view store helper', () => {
|
||||||
await store.dispatch('test/afterExistingRowDeleted', {
|
await store.dispatch('test/afterExistingRowDeleted', {
|
||||||
view,
|
view,
|
||||||
fields,
|
fields,
|
||||||
primary,
|
|
||||||
row: {
|
row: {
|
||||||
id: 14,
|
id: 14,
|
||||||
order: '14.00000000000000000000',
|
order: '14.00000000000000000000',
|
||||||
|
@ -1932,13 +1890,14 @@ describe('Buffered rows view store helper', () => {
|
||||||
],
|
],
|
||||||
sortings: [],
|
sortings: [],
|
||||||
}
|
}
|
||||||
const fields = []
|
const fields = [
|
||||||
const primary = {
|
{
|
||||||
id: 1,
|
id: 1,
|
||||||
name: 'Test 1',
|
name: 'Test 1',
|
||||||
type: 'text',
|
type: 'text',
|
||||||
primary: true,
|
primary: true,
|
||||||
}
|
},
|
||||||
|
]
|
||||||
const populateRow = (row) => {
|
const populateRow = (row) => {
|
||||||
row._ = {}
|
row._ = {}
|
||||||
return row
|
return row
|
||||||
|
@ -1973,7 +1932,6 @@ describe('Buffered rows view store helper', () => {
|
||||||
await store.dispatch('test/afterExistingRowDeleted', {
|
await store.dispatch('test/afterExistingRowDeleted', {
|
||||||
view,
|
view,
|
||||||
fields,
|
fields,
|
||||||
primary,
|
|
||||||
row: {
|
row: {
|
||||||
id: 100,
|
id: 100,
|
||||||
order: '100.00000000000000000000',
|
order: '100.00000000000000000000',
|
||||||
|
@ -2072,8 +2030,7 @@ describe('Buffered rows search', () => {
|
||||||
store.registerModule(storeName, bufferedRowsModule)
|
store.registerModule(storeName, bufferedRowsModule)
|
||||||
|
|
||||||
await store.dispatch(`${storeName}/refresh`, {
|
await store.dispatch(`${storeName}/refresh`, {
|
||||||
fields: [],
|
fields: [createPrimaryField()],
|
||||||
primary: createPrimaryField(),
|
|
||||||
})
|
})
|
||||||
|
|
||||||
const rowsInStore = store.getters[`${storeName}/getRows`]
|
const rowsInStore = store.getters[`${storeName}/getRows`]
|
||||||
|
@ -2097,8 +2054,7 @@ describe('Buffered rows search', () => {
|
||||||
|
|
||||||
await store.dispatch(`${storeName}/afterNewRowCreated`, {
|
await store.dispatch(`${storeName}/afterNewRowCreated`, {
|
||||||
view,
|
view,
|
||||||
fields: [],
|
fields: [createPrimaryField()],
|
||||||
primary: createPrimaryField(),
|
|
||||||
values: newMatchingRow,
|
values: newMatchingRow,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -2124,7 +2080,6 @@ describe('Buffered rows search', () => {
|
||||||
await store.dispatch(`${storeName}/afterNewRowCreated`, {
|
await store.dispatch(`${storeName}/afterNewRowCreated`, {
|
||||||
view,
|
view,
|
||||||
fields: [],
|
fields: [],
|
||||||
primary: createPrimaryField(),
|
|
||||||
values: newNotMatchingRow,
|
values: newNotMatchingRow,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -2152,8 +2107,7 @@ describe('Buffered rows search', () => {
|
||||||
|
|
||||||
await store.dispatch(`${storeName}/afterExistingRowUpdated`, {
|
await store.dispatch(`${storeName}/afterExistingRowUpdated`, {
|
||||||
view,
|
view,
|
||||||
fields: [],
|
fields: [createPrimaryField()],
|
||||||
primary: createPrimaryField(),
|
|
||||||
row: matchingRow,
|
row: matchingRow,
|
||||||
values: newValues,
|
values: newValues,
|
||||||
})
|
})
|
||||||
|
|
|
@ -110,13 +110,11 @@ describe('Grid view store', () => {
|
||||||
sortings: [],
|
sortings: [],
|
||||||
}
|
}
|
||||||
const fields = []
|
const fields = []
|
||||||
const primary = {}
|
|
||||||
const getScrollTop = () => 0
|
const getScrollTop = () => 0
|
||||||
|
|
||||||
await store.dispatch('grid/createdNewRow', {
|
await store.dispatch('grid/createdNewRow', {
|
||||||
view,
|
view,
|
||||||
fields,
|
fields,
|
||||||
primary,
|
|
||||||
values: { id: 1, order: '1.00000000000000000000' },
|
values: { id: 1, order: '1.00000000000000000000' },
|
||||||
getScrollTop,
|
getScrollTop,
|
||||||
})
|
})
|
||||||
|
@ -129,7 +127,6 @@ describe('Grid view store', () => {
|
||||||
await store.dispatch('grid/createdNewRow', {
|
await store.dispatch('grid/createdNewRow', {
|
||||||
view,
|
view,
|
||||||
fields,
|
fields,
|
||||||
primary,
|
|
||||||
values: { id: 8, order: '4.50000000000000000000' },
|
values: { id: 8, order: '4.50000000000000000000' },
|
||||||
getScrollTop,
|
getScrollTop,
|
||||||
})
|
})
|
||||||
|
@ -143,7 +140,6 @@ describe('Grid view store', () => {
|
||||||
await store.dispatch('grid/createdNewRow', {
|
await store.dispatch('grid/createdNewRow', {
|
||||||
view,
|
view,
|
||||||
fields,
|
fields,
|
||||||
primary,
|
|
||||||
values: { id: 102, order: '102.00000000000000000000' },
|
values: { id: 102, order: '102.00000000000000000000' },
|
||||||
getScrollTop,
|
getScrollTop,
|
||||||
})
|
})
|
||||||
|
@ -166,7 +162,6 @@ describe('Grid view store', () => {
|
||||||
await store.dispatch('grid/createdNewRow', {
|
await store.dispatch('grid/createdNewRow', {
|
||||||
view,
|
view,
|
||||||
fields,
|
fields,
|
||||||
primary,
|
|
||||||
values: { id: 2, order: '2.00000000000000000000' },
|
values: { id: 2, order: '2.00000000000000000000' },
|
||||||
getScrollTop,
|
getScrollTop,
|
||||||
})
|
})
|
||||||
|
@ -194,13 +189,14 @@ describe('Grid view store', () => {
|
||||||
],
|
],
|
||||||
sortings: [],
|
sortings: [],
|
||||||
},
|
},
|
||||||
fields,
|
fields: [
|
||||||
primary: {
|
{
|
||||||
id: 1,
|
id: 1,
|
||||||
name: 'Test 1',
|
name: 'Test 1',
|
||||||
type: 'text',
|
type: 'text',
|
||||||
primary: true,
|
primary: true,
|
||||||
},
|
},
|
||||||
|
],
|
||||||
values: { id: 16, order: '11.50000000000000000000', field_1: 'value' },
|
values: { id: 16, order: '11.50000000000000000000', field_1: 'value' },
|
||||||
getScrollTop,
|
getScrollTop,
|
||||||
})
|
})
|
||||||
|
@ -250,19 +246,19 @@ describe('Grid view store', () => {
|
||||||
],
|
],
|
||||||
sortings: [],
|
sortings: [],
|
||||||
}
|
}
|
||||||
const fields = []
|
const fields = [
|
||||||
const primary = {
|
{
|
||||||
id: 1,
|
id: 1,
|
||||||
name: 'Test 1',
|
name: 'Test 1',
|
||||||
type: 'text',
|
type: 'text',
|
||||||
primary: true,
|
primary: true,
|
||||||
}
|
},
|
||||||
|
]
|
||||||
const getScrollTop = () => 0
|
const getScrollTop = () => 0
|
||||||
|
|
||||||
await store.dispatch('grid/updatedExistingRow', {
|
await store.dispatch('grid/updatedExistingRow', {
|
||||||
view,
|
view,
|
||||||
fields,
|
fields,
|
||||||
primary,
|
|
||||||
row: { id: 2, order: '2.00000000000000000000', field_1: 'Value 2' },
|
row: { id: 2, order: '2.00000000000000000000', field_1: 'Value 2' },
|
||||||
values: { field_1: 'Value 2 updated' },
|
values: { field_1: 'Value 2 updated' },
|
||||||
getScrollTop,
|
getScrollTop,
|
||||||
|
@ -282,7 +278,6 @@ describe('Grid view store', () => {
|
||||||
await store.dispatch('grid/updatedExistingRow', {
|
await store.dispatch('grid/updatedExistingRow', {
|
||||||
view,
|
view,
|
||||||
fields,
|
fields,
|
||||||
primary,
|
|
||||||
row: { id: 1, order: '1.00000000000000000000', field_1: 'Value 1' },
|
row: { id: 1, order: '1.00000000000000000000', field_1: 'Value 1' },
|
||||||
values: { field_1: 'Value 1 updated' },
|
values: { field_1: 'Value 1 updated' },
|
||||||
getScrollTop,
|
getScrollTop,
|
||||||
|
@ -301,7 +296,6 @@ describe('Grid view store', () => {
|
||||||
await store.dispatch('grid/updatedExistingRow', {
|
await store.dispatch('grid/updatedExistingRow', {
|
||||||
view,
|
view,
|
||||||
fields,
|
fields,
|
||||||
primary,
|
|
||||||
row: { id: 3, order: '3.00000000000000000000', field_1: 'Value 3' },
|
row: { id: 3, order: '3.00000000000000000000', field_1: 'Value 3' },
|
||||||
values: { field_1: 'Value 3 updated' },
|
values: { field_1: 'Value 3 updated' },
|
||||||
getScrollTop,
|
getScrollTop,
|
||||||
|
@ -320,7 +314,6 @@ describe('Grid view store', () => {
|
||||||
await store.dispatch('grid/updatedExistingRow', {
|
await store.dispatch('grid/updatedExistingRow', {
|
||||||
view,
|
view,
|
||||||
fields,
|
fields,
|
||||||
primary,
|
|
||||||
row: { id: 4, order: '4.00000000000000000000', field_1: 'empty' },
|
row: { id: 4, order: '4.00000000000000000000', field_1: 'empty' },
|
||||||
values: { field_1: 'Value 4 updated' },
|
values: { field_1: 'Value 4 updated' },
|
||||||
getScrollTop,
|
getScrollTop,
|
||||||
|
@ -341,7 +334,6 @@ describe('Grid view store', () => {
|
||||||
await store.dispatch('grid/updatedExistingRow', {
|
await store.dispatch('grid/updatedExistingRow', {
|
||||||
view,
|
view,
|
||||||
fields,
|
fields,
|
||||||
primary,
|
|
||||||
row: {
|
row: {
|
||||||
id: 4,
|
id: 4,
|
||||||
order: '4.00000000000000000000',
|
order: '4.00000000000000000000',
|
||||||
|
@ -378,7 +370,6 @@ describe('Grid view store', () => {
|
||||||
await store.dispatch('grid/updatedExistingRow', {
|
await store.dispatch('grid/updatedExistingRow', {
|
||||||
view,
|
view,
|
||||||
fields,
|
fields,
|
||||||
primary,
|
|
||||||
row: { id: 10, order: '10.00000000000000000000', field_1: 'Value 10' },
|
row: { id: 10, order: '10.00000000000000000000', field_1: 'Value 10' },
|
||||||
values: { field_1: 'Value 10 updated' },
|
values: { field_1: 'Value 10 updated' },
|
||||||
getScrollTop,
|
getScrollTop,
|
||||||
|
@ -403,7 +394,6 @@ describe('Grid view store', () => {
|
||||||
await store.dispatch('grid/updatedExistingRow', {
|
await store.dispatch('grid/updatedExistingRow', {
|
||||||
view,
|
view,
|
||||||
fields,
|
fields,
|
||||||
primary,
|
|
||||||
row: { id: 15, order: '15.00000000000000000000', field_1: 'Value 15' },
|
row: { id: 15, order: '15.00000000000000000000', field_1: 'Value 15' },
|
||||||
values: { field_1: 'Value 15 updated' },
|
values: { field_1: 'Value 15 updated' },
|
||||||
getScrollTop,
|
getScrollTop,
|
||||||
|
@ -425,7 +415,6 @@ describe('Grid view store', () => {
|
||||||
await store.dispatch('grid/updatedExistingRow', {
|
await store.dispatch('grid/updatedExistingRow', {
|
||||||
view,
|
view,
|
||||||
fields,
|
fields,
|
||||||
primary,
|
|
||||||
row: { id: 12, order: '12.00000000000000000000', field_1: 'Value 12' },
|
row: { id: 12, order: '12.00000000000000000000', field_1: 'Value 12' },
|
||||||
values: {
|
values: {
|
||||||
order: '13.50000000000000000000',
|
order: '13.50000000000000000000',
|
||||||
|
@ -451,7 +440,6 @@ describe('Grid view store', () => {
|
||||||
await store.dispatch('grid/updatedExistingRow', {
|
await store.dispatch('grid/updatedExistingRow', {
|
||||||
view,
|
view,
|
||||||
fields,
|
fields,
|
||||||
primary,
|
|
||||||
row: {
|
row: {
|
||||||
id: 12,
|
id: 12,
|
||||||
order: '13.50000000000000000000',
|
order: '13.50000000000000000000',
|
||||||
|
@ -478,7 +466,6 @@ describe('Grid view store', () => {
|
||||||
await store.dispatch('grid/updatedExistingRow', {
|
await store.dispatch('grid/updatedExistingRow', {
|
||||||
view,
|
view,
|
||||||
fields,
|
fields,
|
||||||
primary,
|
|
||||||
row: {
|
row: {
|
||||||
id: 13,
|
id: 13,
|
||||||
order: '13.00000000000000000000',
|
order: '13.00000000000000000000',
|
||||||
|
@ -502,7 +489,6 @@ describe('Grid view store', () => {
|
||||||
await store.dispatch('grid/updatedExistingRow', {
|
await store.dispatch('grid/updatedExistingRow', {
|
||||||
view,
|
view,
|
||||||
fields,
|
fields,
|
||||||
primary,
|
|
||||||
row: {
|
row: {
|
||||||
id: 2,
|
id: 2,
|
||||||
order: '2.00000000000000000000',
|
order: '2.00000000000000000000',
|
||||||
|
@ -527,7 +513,6 @@ describe('Grid view store', () => {
|
||||||
await store.dispatch('grid/updatedExistingRow', {
|
await store.dispatch('grid/updatedExistingRow', {
|
||||||
view,
|
view,
|
||||||
fields,
|
fields,
|
||||||
primary,
|
|
||||||
row: {
|
row: {
|
||||||
id: 2,
|
id: 2,
|
||||||
order: '20.99999999999999999999',
|
order: '20.99999999999999999999',
|
||||||
|
@ -565,7 +550,6 @@ describe('Grid view store', () => {
|
||||||
await store.dispatch('grid/updatedExistingRow', {
|
await store.dispatch('grid/updatedExistingRow', {
|
||||||
view,
|
view,
|
||||||
fields,
|
fields,
|
||||||
primary,
|
|
||||||
row: {
|
row: {
|
||||||
id: 11,
|
id: 11,
|
||||||
order: '14.99999999999999999996',
|
order: '14.99999999999999999996',
|
||||||
|
@ -610,7 +594,6 @@ describe('Grid view store', () => {
|
||||||
await store.dispatch('grid/updatedExistingRow', {
|
await store.dispatch('grid/updatedExistingRow', {
|
||||||
view,
|
view,
|
||||||
fields,
|
fields,
|
||||||
primary,
|
|
||||||
row: {
|
row: {
|
||||||
id: 11,
|
id: 11,
|
||||||
order: '14.99999999999999999999',
|
order: '14.99999999999999999999',
|
||||||
|
@ -673,13 +656,11 @@ describe('Grid view store', () => {
|
||||||
sortings: [],
|
sortings: [],
|
||||||
}
|
}
|
||||||
const fields = []
|
const fields = []
|
||||||
const primary = {}
|
|
||||||
const getScrollTop = () => 0
|
const getScrollTop = () => 0
|
||||||
|
|
||||||
await store.dispatch('grid/deletedExistingRow', {
|
await store.dispatch('grid/deletedExistingRow', {
|
||||||
view,
|
view,
|
||||||
fields,
|
fields,
|
||||||
primary,
|
|
||||||
row: { id: 3, order: '3.00000000000000000000' },
|
row: { id: 3, order: '3.00000000000000000000' },
|
||||||
getScrollTop,
|
getScrollTop,
|
||||||
})
|
})
|
||||||
|
@ -697,7 +678,6 @@ describe('Grid view store', () => {
|
||||||
await store.dispatch('grid/deletedExistingRow', {
|
await store.dispatch('grid/deletedExistingRow', {
|
||||||
view,
|
view,
|
||||||
fields,
|
fields,
|
||||||
primary,
|
|
||||||
row: { id: 20, order: '20.00000000000000000000' },
|
row: { id: 20, order: '20.00000000000000000000' },
|
||||||
getScrollTop,
|
getScrollTop,
|
||||||
})
|
})
|
||||||
|
@ -715,7 +695,6 @@ describe('Grid view store', () => {
|
||||||
await store.dispatch('grid/deletedExistingRow', {
|
await store.dispatch('grid/deletedExistingRow', {
|
||||||
view,
|
view,
|
||||||
fields,
|
fields,
|
||||||
primary,
|
|
||||||
row: { id: 13, order: '13.00000000000000000000' },
|
row: { id: 13, order: '13.00000000000000000000' },
|
||||||
getScrollTop,
|
getScrollTop,
|
||||||
})
|
})
|
||||||
|
@ -747,13 +726,14 @@ describe('Grid view store', () => {
|
||||||
],
|
],
|
||||||
sortings: [],
|
sortings: [],
|
||||||
},
|
},
|
||||||
fields,
|
fields: [
|
||||||
primary: {
|
{
|
||||||
id: 1,
|
id: 1,
|
||||||
name: 'Test 1',
|
name: 'Test 1',
|
||||||
type: 'text',
|
type: 'text',
|
||||||
primary: true,
|
primary: true,
|
||||||
},
|
},
|
||||||
|
],
|
||||||
row: { id: 16, order: '11.50000000000000000000', field_1: 'value' },
|
row: { id: 16, order: '11.50000000000000000000', field_1: 'value' },
|
||||||
getScrollTop,
|
getScrollTop,
|
||||||
})
|
})
|
||||||
|
@ -783,13 +763,11 @@ describe('Grid view store', () => {
|
||||||
sortings: [],
|
sortings: [],
|
||||||
}
|
}
|
||||||
const fields = []
|
const fields = []
|
||||||
const primary = {}
|
|
||||||
const getScrollTop = () => 0
|
const getScrollTop = () => 0
|
||||||
|
|
||||||
await store.dispatch('grid/createdNewRow', {
|
await store.dispatch('grid/createdNewRow', {
|
||||||
view,
|
view,
|
||||||
fields,
|
fields,
|
||||||
primary,
|
|
||||||
values: { id: 1, order: '1.00000000000000000000' },
|
values: { id: 1, order: '1.00000000000000000000' },
|
||||||
metadata: { test: 'test' },
|
metadata: { test: 'test' },
|
||||||
getScrollTop,
|
getScrollTop,
|
||||||
|
@ -801,7 +779,6 @@ describe('Grid view store', () => {
|
||||||
await store.dispatch('grid/updatedExistingRow', {
|
await store.dispatch('grid/updatedExistingRow', {
|
||||||
view,
|
view,
|
||||||
fields,
|
fields,
|
||||||
primary,
|
|
||||||
row: { id: 1, order: '1.00000000000000000000' },
|
row: { id: 1, order: '1.00000000000000000000' },
|
||||||
values: { field_1: 'Value updated' },
|
values: { field_1: 'Value updated' },
|
||||||
metadata: { test: 'test updated' },
|
metadata: { test: 'test updated' },
|
||||||
|
|
42
web-frontend/test/unit/database/utils/field.spec.js
Normal file
42
web-frontend/test/unit/database/utils/field.spec.js
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
import { getPrimaryOrFirstField } from '@baserow/modules/database/utils/field'
|
||||||
|
|
||||||
|
describe('test field utils', () => {
|
||||||
|
it('should find the primary field in a list of fields', () => {
|
||||||
|
const fields = [
|
||||||
|
{
|
||||||
|
name: 'id',
|
||||||
|
type: 'integer',
|
||||||
|
primary: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'name',
|
||||||
|
type: 'string',
|
||||||
|
primary: false,
|
||||||
|
},
|
||||||
|
]
|
||||||
|
const primaryField = getPrimaryOrFirstField(fields)
|
||||||
|
expect(primaryField).toEqual(fields[0])
|
||||||
|
})
|
||||||
|
|
||||||
|
it('should return the first field if no primary field is found', () => {
|
||||||
|
const fields = [
|
||||||
|
{
|
||||||
|
name: 'id',
|
||||||
|
type: 'integer',
|
||||||
|
primary: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'name',
|
||||||
|
type: 'string',
|
||||||
|
primary: false,
|
||||||
|
},
|
||||||
|
]
|
||||||
|
const primaryField = getPrimaryOrFirstField(fields)
|
||||||
|
expect(primaryField).toEqual(fields[0])
|
||||||
|
})
|
||||||
|
|
||||||
|
it('should return undefined if no fields are provided', () => {
|
||||||
|
const primaryField = getPrimaryOrFirstField([])
|
||||||
|
expect(primaryField).toBeUndefined()
|
||||||
|
})
|
||||||
|
})
|
|
@ -58,7 +58,6 @@ describe('View Filter Tests', () => {
|
||||||
await store.dispatch('page/view/grid/fetchInitial', {
|
await store.dispatch('page/view/grid/fetchInitial', {
|
||||||
gridId: 1,
|
gridId: 1,
|
||||||
fields: [field],
|
fields: [field],
|
||||||
primary: {},
|
|
||||||
})
|
})
|
||||||
await store.dispatch('view/fetchAll', { id: 1 })
|
await store.dispatch('view/fetchAll', { id: 1 })
|
||||||
}
|
}
|
||||||
|
@ -100,12 +99,13 @@ describe('View Filter Tests', () => {
|
||||||
async function editFieldWithoutSavingNewValue(row, newValue) {
|
async function editFieldWithoutSavingNewValue(row, newValue) {
|
||||||
await store.dispatch('page/view/grid/updateMatchFilters', {
|
await store.dispatch('page/view/grid/updateMatchFilters', {
|
||||||
view: store.getters['view/first'],
|
view: store.getters['view/first'],
|
||||||
fields: [],
|
fields: [
|
||||||
primary: {
|
{
|
||||||
id: 1,
|
id: 1,
|
||||||
type: 'file',
|
type: 'file',
|
||||||
primary: true,
|
primary: true,
|
||||||
},
|
},
|
||||||
|
],
|
||||||
row,
|
row,
|
||||||
overrides: {
|
overrides: {
|
||||||
field_1: newValue,
|
field_1: newValue,
|
||||||
|
|
Loading…
Add table
Reference in a new issue