Commit 0b9454cf authored by Harald Sitter's avatar Harald Sitter

prevent saving without a master tag and offer adding it automatically

parent edabbcaf
......@@ -29,7 +29,31 @@ import privateneedler 1.0 as Needler
ApplicationWindow {
property string path
MessageDialog {
property string base
id: missingMasterTagDialog
title: "Missing master tag"
text: "All needles must be tagged with their basename, this needle is missing it though. This could mean that you misspelled it or simply forgot. <br/>Should I add it automatically?"
informativeText: ""
icon: StandardIcon.Critical
standardButtons: StandardButton.Yes | StandardButton.No
onYes: {
console.debug("ADDING " + base)
selectorModel.tags.push(base)
selectorModel.tags = selectorModel.tags // Reassign to trigger reload
save()
}
}
function save() {
// If the basename isn't in the tags we'll wanna raise a warning.
var base = baseName(path)
if (selectorModel.tags.indexOf(base) < 0) {
missingMasterTagDialog.base = base
missingMasterTagDialog.visible = true
return
}
write(selectorModel.toJSON())
}
......@@ -42,6 +66,12 @@ ApplicationWindow {
return str;
}
function baseName(str)
{
var str = new String(str) // Make sure its a stringy.
return str.substring(str.lastIndexOf('/') + 1);
}
function load(url) {
path = withoutExtension(url.toString())
var json = path + ".json"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment