-
Notifications
You must be signed in to change notification settings - Fork 408
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
server-demo: Create input to edit list of LWM2M path
- Loading branch information
1 parent
1c98fb2
commit 8965f21
Showing
2 changed files
with
82 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
leshan-server-core-demo/webapp/src/components/path/PathsInput.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
<!----------------------------------------------------------------------------- | ||
* Copyright (c) 2021 Sierra Wireless and others. | ||
* | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v2.0 | ||
* and Eclipse Distribution License v1.0 which accompany this distribution. | ||
* | ||
* The Eclipse Public License is available at | ||
* http://www.eclipse.org/legal/epl-v20.html | ||
* and the Eclipse Distribution License is available at | ||
* http://www.eclipse.org/org/documents/edl-v10.html. | ||
-----------------------------------------------------------------------------> | ||
<template> | ||
<div class="grey lighten-4 pa-4 mb-1"> | ||
<span class="pa-2"> | ||
<v-btn small @click="addPath"> {{ addButtonText }} </v-btn> | ||
</span> | ||
<v-btn small @click="removeAllPath"> Remove All </v-btn> | ||
<div v-for="(path, index) in value" :key="index"> | ||
<v-text-field | ||
:value="path" | ||
:rules="[ | ||
(v) => !!v || 'path can not be empty required', | ||
(v) => | ||
!v || | ||
/^((\/([1-9][0-9]{0,4}|[0])){0,4})$|^\/$/.test(v) || | ||
'invalid path', | ||
]" | ||
placeholder="a path to a LWM2M node (e.g. /3/0/1 or /3/0/11/0)" | ||
required | ||
dense | ||
@input="updatePath(index, $event)" | ||
append-outer-icon="mdi-delete" | ||
@click:append-outer="removePath(index)" | ||
></v-text-field> | ||
</div> | ||
</div> | ||
</template> | ||
<script> | ||
export default { | ||
props: { | ||
value: Array, // path to edit | ||
addButtonText: { | ||
default: "Add Path", | ||
type: String, | ||
}, // label of Add button | ||
}, | ||
methods: { | ||
addPath() { | ||
this.$emit("input", [...this.value, ""]); | ||
}, | ||
removeAllPath() { | ||
this.$emit("input", []); | ||
}, | ||
updatePath(index, path) { | ||
let res = [...this.value]; | ||
res.splice(index, 1, path); | ||
this.$emit("input", res); | ||
}, | ||
removePath(index) { | ||
let res = [...this.value]; | ||
res.splice(index, 1); | ||
this.$emit("input", res); | ||
}, | ||
}, | ||
}; | ||
</script> |