mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-11-23 10: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:
parent
5226c7a2fa
commit
d0636f2124
@ -6,6 +6,7 @@ CloseAll/Button: close all
|
||||
ConfirmCancelTiddler: Do you wish to discard changes to 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>>/>"?
|
||||
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 (`.`)
|
||||
MissingTiddler/Hint: Missing tiddler "<$text text=<<currentTiddler>>/>" - click {{$:/core/images/edit-button}} to create
|
||||
RecentChanges/DateFormat: DDth MMM YYYY
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user