1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-11-27 12:07:19 +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:
Devin Weaver 2014-04-25 09:40:24 -04:00
parent 5226c7a2fa
commit d0636f2124
2 changed files with 22 additions and 2 deletions

View File

@ -6,6 +6,7 @@ CloseAll/Button: close all
ConfirmCancelTiddler: Do you wish to discard changes to the tiddler "<$text text=<<title>>/>"? ConfirmCancelTiddler: Do you wish to discard changes to the tiddler "<$text text=<<title>>/>"?
ConfirmDeleteTiddler: Do you wish to delete the tiddler "<$text text=<<title>>/>"? ConfirmDeleteTiddler: Do you wish to delete the tiddler "<$text text=<<title>>/>"?
ConfirmOverwriteTiddler: Do you wish to overwrite the tiddler "<$text text=<<title>>/>"? ConfirmOverwriteTiddler: Do you wish to overwrite the tiddler "<$text text=<<title>>/>"?
ConfirmEditShadowTiddler: Your about to edit a ShaddowTiddler. This will override the default system making upgrading non-trivial. Are you sure you want to edit "<$text text=<<title>>/>"?
InvalidFieldName: Illegal characters in field name "<$text text=<<fieldName>>/>". Fields can only contain lowercase letters and the characters underscore (`_`), hyphen (`-`) and period (`.`) InvalidFieldName: Illegal characters in field name "<$text text=<<fieldName>>/>". Fields can only contain lowercase letters and the characters underscore (`_`), hyphen (`-`) and period (`.`)
MissingTiddler/Hint: Missing tiddler "<$text text=<<currentTiddler>>/>" - click {{$:/core/images/edit-button}} to create MissingTiddler/Hint: Missing tiddler "<$text text=<<currentTiddler>>/>" - click {{$:/core/images/edit-button}} to create
RecentChanges/DateFormat: DDth MMM YYYY RecentChanges/DateFormat: DDth MMM YYYY

View File

@ -181,9 +181,28 @@ NavigatorWidget.prototype.handleCloseOtherTiddlersEvent = function(event) {
// Place a tiddler in edit mode // Place a tiddler in edit mode
NavigatorWidget.prototype.handleEditTiddlerEvent = function(event) { 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 // Replace the specified tiddler with a draft in edit mode
var title = event.param || event.tiddlerTitle, var draftTiddler = this.makeDraftTiddler(title),
draftTiddler = this.makeDraftTiddler(title),
draftTitle = draftTiddler.fields.title, draftTitle = draftTiddler.fields.title,
storyList = this.getStoryList(); storyList = this.getStoryList();
this.removeTitleFromStory(storyList,draftTitle); this.removeTitleFromStory(storyList,draftTitle);