Skip to content
Snippets Groups Projects
Commit 8b3e1530 authored by Nils Brinckmann's avatar Nils Brinckmann
Browse files

Merge branch '217-fix-save-after-updates-for-mount-actions' into 'master'

Add save for updates of mounts and disable some update functionality

See merge request !192
parents bdaabe63 0a6c4418
No related branches found
No related tags found
1 merge request!192Add save for updates of mounts and disable some update functionality
......@@ -158,60 +158,9 @@ permissions and limitations under the Licence.
<div
v-if="value && !readonly"
>
<v-btn v-if="isMountedOnSelectedDate" @click="overwriteExistingMountAction">
Update
<v-btn @click="overwriteExistingMountAction">
Update existing mount
</v-btn>
<v-btn v-else @click="addNewMountAction">
Update
</v-btn>
<v-menu
v-if="!isMountedOnSelectedDate"
close-on-click
close-on-content-click
offset-x
right
z-indx="999"
>
<template #activator="{ on }">
<v-btn
data-role="property menu"
icon
small
v-on="on"
>
<v-icon
dense
small
>
mdi-dots-vertical
</v-icon>
</v-btn>
</template>
<v-list>
<v-list-item
dense
@click="overwriteExistingMountAction"
>
<v-list-item-content>
<v-list-item-title>
Update for {{ value.unpack().date | dateToDateTimeStringHHMM }}
<span class="text-caption text--secondary">(UTC)</span>
</v-list-item-title>
</v-list-item-content>
</v-list-item>
<v-list-item
dense
@click="addNewMountAction"
>
<v-list-item-content>
<v-list-item-title>
Update for {{ selectedDate | dateToDateTimeStringHHMM }}
<span class="text-caption text--secondary">(UTC)</span>
</v-list-item-title>
</v-list-item-content>
</v-list-item>
</v-list>
</v-menu>
</div>
</v-expansion-panel-content>
</v-expansion-panel>
......@@ -391,24 +340,6 @@ readonly currentUserMail:string|null
}
}
addNewMountAction () {
if (this.validateMountUpdateForm()) {
this.$emit(
'addNewMountAction',
this.value,
{
offsetX: this.offsetX,
offsetY: this.offsetY,
offsetZ: this.offsetZ,
contact: this.mountContact,
description: this.mountDescription
}
)
} else {
this.$store.commit('snackbar/setError', 'Please correct the errors')
}
}
selectCurrentUserAsMountContact () {
if (this.currentUserMail) {
const userIndex = this.contacts.findIndex(c => c.email === this.currentUserMail)
......
......@@ -214,7 +214,7 @@ export class Configuration implements IConfiguration {
this._dynamicLocationEndActions = newActions
}
static createFromObject (someObject: Configuration): Configuration {
static createFromObject (someObject: IConfiguration): Configuration {
const newObject = new Configuration()
newObject.id = someObject.id
......
......@@ -81,7 +81,6 @@ permissions and limitations under the Licence.
:current-user-mail="currentUserMail"
@remove="removeSelectedNode"
@overwriteExistingMountAction="overwriteExistingMountAction"
@addNewMountAction="addNewMountAction"
/>
<ConfigurationsPlatformDeviceSearch
v-if="$auth.loggedIn && (!selectedNode || selectedNode.isPlatform())"
......@@ -234,10 +233,12 @@ export default class ConfigurationPlatformsAndDevices extends Vue {
overwriteExistingMountAction (node: ConfigurationsTreeNode, newSettings: any) {
ConfigurationHelper.overwriteExistingMountAction(node, newSettings)
}
addNewMountAction (node: ConfigurationsTreeNode, newSettings: any) {
ConfigurationHelper.addNewMountAction(node, newSettings, this.configuration, this.selectedDate, this.selectedNode)
// The overwriteExistingMountAction helper overwrites the mount action
// directly in the tree & the configuration.
// We don't need to set those updated mount action additionally
// in the configuration.
// All what is left is to save our change.
this.save()
}
isPlatformInTree (platform: Platform): boolean {
......
......@@ -96,7 +96,7 @@ import { Component, Vue, Prop } from 'nuxt-property-decorator'
import DeviceBasicData from '@/components/DeviceBasicData.vue'
import { Device } from '@/models/Device'
import DeviceDeleteDialog from '@/components/device/DeviceDeleteDialog.vue'
import DeviceDeleteDialog from '@/components/devices/DeviceDeleteDialog.vue'
import DotMenu from '@/components/DotMenu.vue'
import DotMenuActionCopy from '@/components/DotMenuActionCopy.vue'
import DotMenuActionDelete from '@/components/DotMenuActionDelete.vue'
......
......@@ -431,7 +431,7 @@ import { DeviceType } from '@/models/DeviceType'
import { Manufacturer } from '@/models/Manufacturer'
import { Status } from '@/models/Status'
import { DeviceSearcher } from '@/services/sms/DeviceApi'
import DeviceDeleteDialog from '@/components/device/DeviceDeleteDialog.vue'
import DeviceDeleteDialog from '@/components/devices/DeviceDeleteDialog.vue'
import DotMenu from '@/components/DotMenu.vue'
import DotMenuActionCopy from '@/components/DotMenuActionCopy.vue'
import DotMenuActionDelete from '@/components/DotMenuActionDelete.vue'
......
......@@ -101,7 +101,7 @@ import PlatformBasicData from '@/components/PlatformBasicData.vue'
import DotMenu from '@/components/DotMenu.vue'
import DotMenuActionCopy from '@/components/DotMenuActionCopy.vue'
import DotMenuActionDelete from '@/components/DotMenuActionDelete.vue'
import PlatformDeleteDialog from '@/components/plarform/PlatformDeleteDialog.vue'
import PlatformDeleteDialog from '@/components/platforms/PlatformDeleteDialog.vue'
@Component({
components: {
......
......@@ -430,7 +430,7 @@ import { Platform } from '@/models/Platform'
import { PlatformType } from '@/models/PlatformType'
import { Status } from '@/models/Status'
import { PlatformSearcher } from '@/services/sms/PlatformApi'
import PlatformDeleteDialog from '@/components/plarform/PlatformDeleteDialog.vue'
import PlatformDeleteDialog from '@/components/platforms/PlatformDeleteDialog.vue'
import DotMenu from '@/components/DotMenu.vue'
import DotMenuActionCopy from '@/components/DotMenuActionCopy.vue'
import DotMenuActionDelete from '@/components/DotMenuActionDelete.vue'
......
......@@ -43,7 +43,14 @@ import { StaticLocationBeginAction } from '@/models/StaticLocationBeginAction'
import { StaticLocationEndAction } from '@/models/StaticLocationEndAction'
import { IActionDateWithTextItem } from '@/utils/configurationInterfaces'
import ConfigurationHelper from '@/utils/configurationHelper'
import { Platform } from '@/models/Platform'
import { PlatformMountAction } from '@/models/PlatformMountAction'
import { Contact } from '@/models/Contact'
import { DeviceMountAction } from '@/models/DeviceMountAction'
import { Device } from '@/models/Device'
import { buildConfigurationTree } from '@/modelUtils/mountHelpers'
import configurationHelper from '@/utils/configurationHelper'
import { PlatformNode } from '@/viewmodels/PlatformNode'
describe('#getActionDatesWithTextByConfiguration', () => {
it('should return a sorted list of action dates', () => {
......@@ -79,7 +86,7 @@ describe('#getActionDatesWithTextByConfiguration', () => {
dynamicLocationEndAction1
]
const selectedDate = DateTime.utc(2021, 10, 6, 12, 0, 0)
const actionDates: IActionDateWithTextItem[] = ConfigurationHelper.getActionDatesWithTextsByConfiguration(configuration, selectedDate, { useMounts: false, useLoctions: true })
const actionDates: IActionDateWithTextItem[] = configurationHelper.getActionDatesWithTextsByConfiguration(configuration, selectedDate, { useMounts: false, useLoctions: true })
expect(actionDates.length).toEqual(8)
expect(actionDates[0]).toHaveProperty('date', DateTime.utc(1999, 8, 1, 10, 0, 0))
......@@ -99,3 +106,122 @@ describe('#getActionDatesWithTextByConfiguration', () => {
// the 7th item is now - which we can't text because of the time
})
})
describe('#addNewMountAction', () => {
it('should add a new platformMountAction to our configuration', () => {
const platform1 = Platform.createFromObject({
shortName: 'platform 1',
id: '111',
longName: '',
platformTypeName: '',
platformTypeUri: '',
persistentIdentifier: '',
serialNumber: '',
inventoryNumber: '',
website: '',
manufacturerName: '',
manufacturerUri: '',
statusName: '',
statusUri: '',
attachments: [],
contacts: [],
model: '',
createdAt: DateTime.utc(2021, 12, 15, 8, 54, 13),
updatedAt: DateTime.utc(2021, 12, 15, 8, 54, 13),
createdByUserId: 1,
updatedByUserId: 1,
description: ''
})
const device1 = Device.createFromObject({
shortName: 'device 1',
id: '222',
longName: '',
deviceTypeName: '',
deviceTypeUri: '',
persistentIdentifier: '',
serialNumber: '',
inventoryNumber: '',
website: '',
manufacturerName: '',
manufacturerUri: '',
statusName: '',
statusUri: '',
attachments: [],
contacts: [],
model: '',
createdAt: DateTime.utc(2021, 12, 15, 8, 54, 13),
updatedAt: DateTime.utc(2021, 12, 15, 8, 54, 13),
createdByUserId: 1,
updatedByUserId: 1,
description: '',
dualUse: false,
properties: [],
customFields: []
})
const contact1 = Contact.createFromObject({
id: '111111',
givenName: 'Homer',
familyName: 'S',
email: 'homer.j@s',
website: ''
})
const platformMountAction1 = PlatformMountAction.createFromObject({
id: '1111',
platform: platform1,
offsetX: 1,
offsetY: 2,
offsetZ: 3,
description: 'This is the very first mount',
contact: contact1,
date: DateTime.utc(2021, 12, 15, 9, 0, 0),
parentPlatform: null
})
const deviceMountAction1 = DeviceMountAction.createFromObject({
id: '1112',
device: device1,
offsetX: -1,
offsetY: -2,
offsetZ: -3,
description: 'Mount of the device on the platform',
contact: contact1,
parentPlatform: platform1,
date: DateTime.utc(2021, 12, 15, 9, 0, 0)
})
const configuration = Configuration.createFromObject({
id: '123',
label: 'test config',
startDate: null,
endDate: null,
projectName: '',
projectUri: '',
staticLocationBeginActions: [],
staticLocationEndActions: [],
dynamicLocationBeginActions: [],
dynamicLocationEndActions: [],
platformMountActions: [platformMountAction1],
platformUnmountActions: [],
deviceMountActions: [deviceMountAction1],
deviceUnmountActions: [],
contacts: [],
status: '',
location: null
})
const selectedDate = DateTime.utc(2021, 12, 15, 9, 15, 0)
const tree = buildConfigurationTree(configuration, selectedDate)
const platformTreeNode: PlatformNode = tree.getPlatformById(platform1.id!)! // id of the platform & not the mount of the platform
expect(platformTreeNode).not.toBeNull()
configurationHelper.addNewMountAction(platformTreeNode, {
offsetX: 29,
offsetY: 30,
offsetZ: 17,
description: 'Changed offsets for platform',
contact: contact1
}, configuration, selectedDate, platformTreeNode)
expect(configuration.platformMountActions.length).toEqual(2)
expect(configuration.platformMountActions[0].offsetX).toEqual(1)
expect(configuration.platformMountActions[1].offsetX).toEqual(29)
})
})
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment