mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-12-14 04:00:28 +00:00
8b60cab6a2
* Update tag-picker.tid * rework kb-driven-input macro to procedures + new syntax * rework change-input-tab to procedure * fix * remove console log :) * replace defines with procedures * fix link-dropdown * fix focus-selector in new-field dropdown * revert changing the footpring of change-input-tab + make it work as procedure * update change-input-tab procedure * refactor change-input-tab procedure and keep tags/Macro tag * simplify complicated filter * add tags/Global tag * remove tags/Global tag * rename variable
157 lines
7.9 KiB
Plaintext
157 lines
7.9 KiB
Plaintext
title: $:/core/ui/EditTemplate/fields
|
|
tags: $:/tags/EditTemplate
|
|
|
|
\procedure lingo-base() $:/language/EditTemplate/
|
|
\function tf.config-title() [[$:/config/EditTemplateFields/Visibility/]addsuffix[$(currentField)$]substitute[]get[text]]
|
|
|
|
\function tf.config-filter() [[hide]] :except[title<tf.config-title>]
|
|
|
|
<!-- Beware this is duplicated from EditTemplate.tid. For details see bug #7054 -->
|
|
\procedure get-field-value-tiddler-filter() [subfilter<get-field-editor-filter>sha256[16]addprefix[/]addprefix<newFieldValueTiddlerPrefix>]
|
|
\procedure get-field-editor-filter() [<newFieldNameTiddler>get[text]else[]] :cascade[all[shadows+tiddlers]tag[$:/tags/FieldEditorFilter]!is[draft]get[text]] :and[!is[blank]else{$:/core/ui/EditTemplate/fieldEditor/default}]
|
|
|
|
\procedure prefix.bracket() [
|
|
\procedure suffix.bracket() ]
|
|
|
|
\function tf.current-tiddler-new-field-selector() [[data-tiddler-title=]addprefix[$(prefix.bracket)$]substitute[]addsuffix<currentTiddlerCSSescaped>addsuffix[$(suffix.bracket)$]substitute[]] .tc-edit-field-add-name-wrapper input :and[join[ ]]
|
|
|
|
\procedure new-field-actions()
|
|
\whitespace trim
|
|
<$action-sendmessage $message="tm-add-field" $name={{{ [<newFieldNameTiddler>get[text]] }}} $value={{{ [<newFieldNameTiddler>get[text]] :map[subfilter<get-field-value-tiddler-filter>get[text]] }}}/>
|
|
<$set name="safeNewFieldValueTiddlerPrefix" value=<<newFieldValueTiddlerPrefix>> emptyValue=<<qualify "$:/temp/NewFieldValue">> >
|
|
<$action-deletetiddler $filter="[<newFieldNameTiddler>] [prefix[$:/temp/NewFieldValue]prefix<safeNewFieldValueTiddlerPrefix>] [<storeTitle>] [<searchListState>]"/>
|
|
</$set>
|
|
<$action-sendmessage $message="tm-focus-selector" $param=<<tf.current-tiddler-new-field-selector>>/>
|
|
\end
|
|
|
|
\procedure delete-state-tiddlers() <$action-deletetiddler $filter="[<newFieldNameTiddler>] [<storeTitle>] [<searchListState>]"/>
|
|
|
|
\procedure cancel-search-actions-inner()
|
|
\whitespace trim
|
|
<$list
|
|
filter="[<storeTitle>has[text]] [<newFieldNameTiddler>has[text]]"
|
|
variable="ignore"
|
|
emptyMessage="<<cancel-delete-tiddler-actions 'cancel'>>">
|
|
<<delete-state-tiddlers>>
|
|
</$list>
|
|
\end
|
|
|
|
\procedure cancel-search-actions()
|
|
\whitespace trim
|
|
<$set name="userInput" value={{{ [<storeTitle>get[text]] }}}>
|
|
<$list
|
|
filter="[<newFieldNameTiddler>get[text]!match<userInput>]"
|
|
emptyMessage="<<cancel-search-actions-inner>>">
|
|
<$action-setfield $tiddler=<<newFieldNameTiddler>> text=<<userInput>>/><$action-setfield $tiddler=<<refreshTitle>> text="yes"/>
|
|
</$list>
|
|
</$set>
|
|
\end
|
|
|
|
\procedure new-field()
|
|
\whitespace trim
|
|
<$vars name={{{ [<newFieldNameTiddler>get[text]] }}}>
|
|
<$reveal type="nomatch" text="" default=<<name>>>
|
|
<$button tooltip={{$:/language/EditTemplate/Fields/Add/Button/Hint}}>
|
|
<$action-sendmessage $message="tm-add-field"
|
|
$name=<<name>>
|
|
$value={{{ [subfilter<get-field-value-tiddler-filter>get[text]] }}}/>
|
|
<$set name="safeNewFieldValueTiddlerPrefix" value=<<newFieldValueTiddlerPrefix>> emptyValue=<<qualify "$:/temp/NewFieldValue">> >
|
|
<$action-deletetiddler $filter="[<newFieldNameTiddler>] [prefix[$:/temp/NewFieldValue]prefix<safeNewFieldValueTiddlerPrefix>] [<storeTitle>] [<searchListState>]"/>
|
|
</$set>
|
|
<<lingo Fields/Add/Button>>
|
|
</$button>
|
|
</$reveal>
|
|
<$reveal type="match" text="" default=<<name>>>
|
|
<$button>
|
|
<<lingo Fields/Add/Button>>
|
|
</$button>
|
|
</$reveal>
|
|
</$vars>
|
|
\end
|
|
\whitespace trim
|
|
|
|
<$set name="newFieldValueTiddlerPrefix" value=<<newFieldValueTiddlerPrefix>> emptyValue=<<qualify "$:/temp/NewFieldValue">> >
|
|
<div class="tc-edit-fields">
|
|
<table class={{{ [all[current]fields[]] :filter[lookup[$:/config/EditTemplateFields/Visibility/]!match[hide]] :and[count[]!match[0]] :and[then[tc-edit-fields]] :else[[tc-edit-fields tc-edit-fields-small]] }}}>
|
|
<tbody>
|
|
<$list filter="[all[current]fields[]] :and[sort[title]]" variable="currentField" storyview="pop">
|
|
<$list filter=<<tf.config-filter>> variable="temp">
|
|
<tr class="tc-edit-field">
|
|
<td class="tc-edit-field-name">
|
|
<$text text=<<currentField>>/>:</td>
|
|
<td class="tc-edit-field-value">
|
|
<$keyboard key="((delete-field))" actions="""<$action-deletefield $field=<<currentField>>/><$set name="currentTiddlerCSSescaped" value={{{ [<currentTiddler>escapecss[]] }}}><$action-sendmessage $message="tm-focus-selector" $param=<<tf.current-tiddler-new-field-selector>>/></$set>""">
|
|
<$transclude tiddler={{{ [<currentField>] :cascade[all[shadows+tiddlers]tag[$:/tags/FieldEditorFilter]!is[draft]get[text]] :and[!is[blank]else{$:/core/ui/EditTemplate/fieldEditor/default}] }}} />
|
|
</$keyboard>
|
|
</td>
|
|
<td class="tc-edit-field-remove">
|
|
<$button class="tc-btn-invisible" tooltip={{$:/language/EditTemplate/Field/Remove/Hint}} aria-label={{$:/language/EditTemplate/Field/Remove/Caption}}>
|
|
<$action-deletefield $field=<<currentField>>/>
|
|
{{$:/core/images/delete-button}}
|
|
</$button>
|
|
</td>
|
|
</tr>
|
|
</$list>
|
|
</$list>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
|
|
<$fieldmangler>
|
|
<div class="tc-edit-field-add">
|
|
<em class="tc-edit tc-small-gap-right">
|
|
<<lingo Fields/Add/Prompt>>
|
|
</em>
|
|
<$vars refreshTitle=<<qualify "$:/temp/fieldname/refresh">> storeTitle=<<newFieldNameInputTiddler>> searchListState=<<newFieldNameSelectionTiddler>>>
|
|
<div class="tc-edit-field-add-name-wrapper">
|
|
<$transclude $variable="keyboard-driven-input" tiddler=<<newFieldNameTiddler>> storeTitle=<<storeTitle>> refreshTitle=<<refreshTitle>>
|
|
selectionStateTitle=<<searchListState>> tag="input" default="" placeholder={{$:/language/EditTemplate/Fields/Add/Name/Placeholder}}
|
|
focusPopup=<<qualify "$:/state/popup/field-dropdown">> class="tc-edit-texteditor tc-popup-handle" tabindex={{$:/config/EditTabIndex}}
|
|
focus={{{ [{$:/config/AutoFocus}match[fields]then[true]] :else[[false]] }}} cancelPopups="yes"
|
|
configTiddlerFilter="[[$:/config/EditMode/fieldname-filter]]" inputCancelActions=<<cancel-search-actions>> />
|
|
<$button popup=<<qualify "$:/state/popup/field-dropdown">> class="tc-btn-invisible tc-btn-dropdown tc-small-gap" tooltip={{$:/language/EditTemplate/Field/Dropdown/Hint}} aria-label={{$:/language/EditTemplate/Field/Dropdown/Caption}}>{{$:/core/images/down-arrow}}</$button>
|
|
<$reveal state=<<qualify "$:/state/popup/field-dropdown">> type="nomatch" text="" default="">
|
|
<div class="tc-block-dropdown tc-edit-type-dropdown">
|
|
<$set name="tv-show-missing-links" value="yes">
|
|
<$linkcatcher to=<<newFieldNameTiddler>>>
|
|
<div class="tc-dropdown-item">
|
|
<<lingo Fields/Add/Dropdown/User>>
|
|
</div>
|
|
<$set name="newFieldName" value={{{ [<storeTitle>get[text]] }}}>
|
|
<$list filter="[!is[shadow]!is[system]fields[]search:title<newFieldName>sort[]] :except[[created]] :except[[creator]] :except[[draft.of]] :except[[draft.title]] :except[[modified]] :except[[modifier]] :except[[tags]] :except[[text]] :except[[title]] :except[[type]]" variable="currentField">
|
|
<$list filter="[<currentField>addsuffix[-primaryList]] :except[<searchListState>get[text]]" emptyMessage="""<$link to=<<currentField>> class="tc-list-item-selected"><$text text=<<currentField>>/></$link>""">
|
|
<$link to=<<currentField>>>
|
|
<$text text=<<currentField>>/>
|
|
</$link>
|
|
</$list>
|
|
</$list>
|
|
<div class="tc-dropdown-item">
|
|
<<lingo Fields/Add/Dropdown/System>>
|
|
</div>
|
|
<$list filter="[fields[]search:title<newFieldName>sort[]] :except[!is[shadow]!is[system]fields[]]" variable="currentField">
|
|
<$list filter="[<currentField>addsuffix[-secondaryList]] :except[<searchListState>get[text]]" emptyMessage="""<$link to=<<currentField>> class="tc-list-item-selected"><$text text=<<currentField>>/></$link>""">
|
|
<$link to=<<currentField>>>
|
|
<$text text=<<currentField>>/>
|
|
</$link>
|
|
</$list>
|
|
</$list>
|
|
</$set>
|
|
</$linkcatcher>
|
|
</$set>
|
|
</div>
|
|
</$reveal>
|
|
</div>
|
|
<$let currentTiddlerCSSescaped={{{ [<currentTiddler>escapecss[]] }}} currentTiddler={{{ [subfilter<get-field-value-tiddler-filter>] }}} currentField="text" currentFieldName={{{ [<newFieldNameTiddler>get[text]] }}}>
|
|
<span class="tc-edit-field-add-value tc-small-gap-right">
|
|
<$keyboard key="((add-field))" actions=<<new-field-actions>>>
|
|
<$transclude tiddler={{{ [subfilter<get-field-editor-filter>] }}} />
|
|
</$keyboard>
|
|
</span>
|
|
<span class="tc-edit-field-add-button">
|
|
<$transclude $variable="new-field"/>
|
|
</span>
|
|
</$let>
|
|
</$vars>
|
|
</div>
|
|
</$fieldmangler>
|
|
</$set> |