refactor of menus

begin work on settings
This commit is contained in:
Simon Vieille
2025-04-09 19:15:43 +02:00
parent ecbe2f7d72
commit 52b2d18a03
26 changed files with 1613 additions and 1667 deletions
+83 -92
View File
@@ -102,101 +102,92 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
</div>
</template>
<script>
import NcModal from '@nextcloud/vue/dist/Components/NcModal.js'
import NcActions from '@nextcloud/vue/dist/Components/NcActions.js'
import NcActionButton from '@nextcloud/vue/dist/Components/NcActionButton.js'
<script setup>
import { NcModal, NcActions, NcActionButton } from '@nextcloud/vue'
import { ref } from 'vue'
export default {
name: 'AdminCategoriesCustom',
components: {
NcModal,
NcActions,
NcActionButton,
},
data() {
return {
input: null,
values: [],
langs: [],
addForm: false,
editForm: false,
newValue: {},
editValue: {},
}
},
mounted() {
this.input = document.querySelector('input[name="categories-custom"]')
this.init()
},
methods: {
init() {
this.values = JSON.parse(this.input.value)
this.langs = JSON.parse(this.input.getAttribute('data-langs'))
},
update() {
this.input.value = JSON.stringify(this.values)
},
showAddForm() {
this.newValue = { id: 'cat' + Math.random().toString().replace('0.', '') }
const { langs, values } = defineProps(['lang', 'values'])
this.addForm = true
},
showEditForm(value) {
this.editValue = { id: value.id }
const input = ref(null)
const values = ref([])
const langs = ref([])
const addForm = ref(false)
const editForm = ref(false)
const newValue = ref({})
const editValue = ref({})
for (let i of this.langs) {
this.editValue[i] = typeof value[i] !== 'undefined' ? value[i] : ''
}
this.editForm = true
},
saveAdd() {
for (let i of this.langs) {
if (!this.newValue[i] || /^\s*$/.test(this.newValue[i])) {
return
}
}
this.values.push(this.newValue)
this.update()
this.hideAddForm()
this.newValue = {}
},
saveEdit() {
for (let i of this.langs) {
if (!this.editValue[i] || /^\s*$/.test(this.editValue[i])) {
return
}
}
for (let i in this.values) {
if (this.values[i].id === this.editValue.id) {
this.values[i] = this.editValue
}
}
this.update()
this.hideEditForm()
},
removeEdit() {
for (let i in this.values) {
if (this.values[i].id === this.editValue.id) {
this.values.splice(i, 1)
}
}
this.update()
this.hideEditForm()
},
hideAddForm() {
this.addForm = false
},
hideEditForm() {
this.editForm = false
},
},
}
// mounted() {
// this.input = document.querySelector('input[name="categories-custom"]')
// this.init()
// },
// methods: {
// init() {
// this.values = JSON.parse(this.input.value)
// this.langs = JSON.parse(this.input.getAttribute('data-langs'))
// },
// update() {
// this.input.value = JSON.stringify(this.values)
// },
// showAddForm() {
// this.newValue = { id: 'cat' + Math.random().toString().replace('0.', '') }
//
// this.addForm = true
// },
// showEditForm(value) {
// this.editValue = { id: value.id }
//
// for (let i of this.langs) {
// this.editValue[i] = typeof value[i] !== 'undefined' ? value[i] : ''
// }
//
// this.editForm = true
// },
// saveAdd() {
// for (let i of this.langs) {
// if (!this.newValue[i] || /^\s*$/.test(this.newValue[i])) {
// return
// }
// }
//
// this.values.push(this.newValue)
// this.update()
// this.hideAddForm()
// this.newValue = {}
// },
// saveEdit() {
// for (let i of this.langs) {
// if (!this.editValue[i] || /^\s*$/.test(this.editValue[i])) {
// return
// }
// }
//
// for (let i in this.values) {
// if (this.values[i].id === this.editValue.id) {
// this.values[i] = this.editValue
// }
// }
//
// this.update()
// this.hideEditForm()
// },
// removeEdit() {
// for (let i in this.values) {
// if (this.values[i].id === this.editValue.id) {
// this.values.splice(i, 1)
// }
// }
//
// this.update()
// this.hideEditForm()
// },
// hideAddForm() {
// this.addForm = false
// },
// hideEditForm() {
// this.editForm = false
// },
// },
// }
</script>
<style>