1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-11-23 10:07:19 +00:00

Import rename (#4928)

* Add UI for renaming tiddlers before import in the import listing

* Removed spurious whitespace
This commit is contained in:
saqimtiaz 2020-10-28 17:03:04 +01:00 committed by GitHub
parent 49b11bc493
commit 9605d94b6c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 41 additions and 5 deletions

View File

@ -13,6 +13,9 @@ Listing/Preview/TextRaw: Text (Raw)
Listing/Preview/Fields: Fields
Listing/Preview/Diff: Diff
Listing/Preview/DiffFields: Diff (Fields)
Listing/Rename/Tooltip: Rename tiddler before importing
Listing/Rename/ConfirmRename : Rename tiddler
Listing/Rename/CancelRename : Cancel
Upgrader/Plugins/Suppressed/Incompatible: Blocked incompatible or obsolete plugin
Upgrader/Plugins/Suppressed/Version: Blocked plugin (due to incoming <<incoming>> being older than existing <<existing>>)
Upgrader/Plugins/Upgraded: Upgraded plugin from <<incoming>> to <<upgraded>>

View File

@ -558,10 +558,14 @@ NavigatorWidget.prototype.handlePerformImportEvent = function(event) {
$tw.utils.each(importData.tiddlers,function(tiddlerFields) {
var title = tiddlerFields.title;
if(title && importTiddler && importTiddler.fields["selection-" + title] !== "unchecked") {
var tiddler = new $tw.Tiddler(tiddlerFields);
if($tw.utils.hop(importTiddler.fields,["rename-" + title])) {
var tiddler = new $tw.Tiddler(tiddlerFields,{title : importTiddler.fields["rename-" + title]});
} else {
var tiddler = new $tw.Tiddler(tiddlerFields);
}
tiddler = $tw.hooks.invokeHook("th-importing-tiddler",tiddler);
self.wiki.addTiddler(tiddler);
importReport.push("# [[" + tiddlerFields.title + "]]");
importReport.push("# [[" + tiddler.fields.title + "]]");
}
});
// Replace the $:/Import tiddler with an import report

View File

@ -10,20 +10,30 @@ message-$(payloadTiddler)$
selection-$(payloadTiddler)$
\end
\define renameField()
rename-$(payloadTiddler)$
\end
\define newImportTitleTiddler() $:/temp/NewImportTitle-$(payloadTiddler)$
\define previewPopupState()
$(currentTiddler)$!!popup-$(payloadTiddler)$
\end
\define renameFieldState()
$:/state/import-rename-$(payloadTiddler)$
\end
\define select-all-actions()
<$list filter="[all[current]plugintiddlers[]sort[title]]" variable="payloadTiddler">
<$action-setfield $field={{{ [<payloadTiddler>addprefix[selection-]] }}} $value={{$:/state/import/select-all}}/>
</$list>
\end
<table>
<table class="tc-import-table">
<tbody>
<tr>
<th>
<th align="left">
<$checkbox tiddler="$:/state/import/select-all" field="text" checked="checked" unchecked="unchecked" default="checked" actions=<<select-all-actions>>>
<<lingo Listing/Select/Caption>>
</$checkbox>
@ -41,16 +51,22 @@ $(currentTiddler)$!!popup-$(payloadTiddler)$
<$checkbox field=<<selectionField>> checked="checked" unchecked="unchecked" default="checked"/>
</td>
<td>
<$reveal type="nomatch" stateTitle=<<renameFieldState>> text="yes" tag="div">
<$reveal type="nomatch" state=<<previewPopupState>> text="yes" tag="div">
<$button class="tc-btn-invisible tc-btn-dropdown" set=<<previewPopupState>> setTo="yes">
{{$:/core/images/right-arrow}}<span class="tc-small-gap-left"><$text text=<<payloadTiddler>>/></span>
{{$:/core/images/right-arrow}}<span class="tc-small-gap-left"><$text text={{{[<currentTiddler>get<renameField>minlength[1]else<payloadTiddler>]}}}/></span>
</$button>
<$button class="tc-btn-invisible" setTitle=<<renameFieldState>> setTo="yes" tooltip={{{[<lingo-base>addsuffix[Listing/Rename/Tooltip]get[text]]}}}>{{$:/core/images/edit-button}}</$button>
</$reveal>
<$reveal type="match" state=<<previewPopupState>> text="yes" tag="div">
<$button class="tc-btn-invisible tc-btn-dropdown" set=<<previewPopupState>> setTo="no">
{{$:/core/images/down-arrow}}<span class="tc-small-gap-left"><$text text=<<payloadTiddler>>/></span>
</$button>
</$reveal>
</$reveal>
<$reveal type="match" stateTitle=<<renameFieldState>> text="yes" tag="div">
<$edit-text tiddler=<<newImportTitleTiddler>> default=<<payloadTiddler>> tag="input" class="tc-import-rename"/><$button class="tc-btn-invisible" setTitle=<<renameFieldState>> setTo="no" tooltip={{{[<lingo-base>addsuffix[Listing/Rename/CancelRename]get[text]]}}}>{{$:/core/images/close-button}}<$action-deletetiddler $tiddler=<<newImportTitleTiddler>>/></$button>&nbsp;<$button class="tc-btn-invisible" setTitle=<<renameFieldState>> setTo="no" tooltip={{{[<lingo-base>addsuffix[Listing/Rename/ConfirmRename]get[text]]}}}>{{$:/core/images/done-button}}<$action-setfield $field=<<renameField>> $value={{{[<newImportTitleTiddler>get[text]minlength[1]else<payloadTiddler>]}}} /><$action-deletetiddler $tiddler=<<newImportTitleTiddler>>/></$button>
</$reveal>
</td>
<td>
<$view field=<<messageField>>/>

View File

@ -2024,6 +2024,19 @@ html body.tc-body.tc-single-tiddler-window {
height: auto;
}
/*
** Import table
*/
.tc-import-table {
width: 100%;
}
input.tc-import-rename {
width: 85%;
margin-right: 0.5em;
}
/*
** Alerts
*/