mirror of
https://github.com/TiddlyWiki/TiddlyWiki5.git
synced 2026-05-02 23:17:26 +00:00
Add a confirmation to edit a shadow tiddler
Should only display the confirmation if the shadow tiddler has not been overridden in the first place. It checks this by looking for the existence of a modified field for which the default system based shadow do not have until a user changes them. This addresses the second line item on issue #570 We will need new translations for the added string `ConfirmEditShadowTiddler`
This commit is contained in:
@@ -181,9 +181,28 @@ NavigatorWidget.prototype.handleCloseOtherTiddlersEvent = function(event) {
|
||||
|
||||
// Place a tiddler in edit mode
|
||||
NavigatorWidget.prototype.handleEditTiddlerEvent = function(event) {
|
||||
function isUnmodifiedShadow(title) {
|
||||
// jshint eqnull:true
|
||||
var tiddler = $tw.wiki.getTiddler(title);
|
||||
return (
|
||||
$tw.wiki.isShadowTiddler(title) &&
|
||||
tiddler.fields.modified == null
|
||||
);
|
||||
}
|
||||
function confirmEditShadow(title) {
|
||||
return confirm($tw.language.getString(
|
||||
"ConfirmEditShadowTiddler",
|
||||
{variables:
|
||||
{title: title}
|
||||
}
|
||||
));
|
||||
}
|
||||
var title = event.param || event.tiddlerTitle;
|
||||
if(isUnmodifiedShadow(title) && !confirmEditShadow(title)) {
|
||||
return false;
|
||||
}
|
||||
// Replace the specified tiddler with a draft in edit mode
|
||||
var title = event.param || event.tiddlerTitle,
|
||||
draftTiddler = this.makeDraftTiddler(title),
|
||||
var draftTiddler = this.makeDraftTiddler(title),
|
||||
draftTitle = draftTiddler.fields.title,
|
||||
storyList = this.getStoryList();
|
||||
this.removeTitleFromStory(storyList,draftTitle);
|
||||
|
||||
Reference in New Issue
Block a user