Error handling for bag and recipe handling
This commit is contained in:
parent
270f62bbb2
commit
541c166863
|
@ -1,10 +1,20 @@
|
||||||
title: MultiWikiServer Administration
|
title: MultiWikiServer Administration
|
||||||
|
|
||||||
\procedure createBag(name,description)
|
\procedure createBag(name,description,errorTiddler)
|
||||||
\procedure completion-createBag()
|
\procedure completion-createBag()
|
||||||
\import [subfilter{$:/core/config/GlobalImportFilter}]
|
\import [subfilter{$:/core/config/GlobalImportFilter}]
|
||||||
<$action-log msg="In completion-createBag"/>
|
<$action-log
|
||||||
<$action-log/>
|
status=<<status>>
|
||||||
|
statusText=<<statusText>>
|
||||||
|
error=<<error>>
|
||||||
|
data=<<data>>
|
||||||
|
headers=<<headers>>
|
||||||
|
/>
|
||||||
|
<%if [<error>match[]] %>
|
||||||
|
<$action-setfield $tiddler=<<errorTiddler>> text=""/>
|
||||||
|
<%else%>
|
||||||
|
<$action-setfield $tiddler=<<errorTiddler>> text=<<data>>/>
|
||||||
|
<%endif%>
|
||||||
\end completion-createBag
|
\end completion-createBag
|
||||||
<$action-sendmessage
|
<$action-sendmessage
|
||||||
$message="tm-http-request"
|
$message="tm-http-request"
|
||||||
|
@ -12,6 +22,7 @@ title: MultiWikiServer Administration
|
||||||
method="PUT"
|
method="PUT"
|
||||||
body=`{"description":"${ [<description>encodeuricomponent[]] }$"}`
|
body=`{"description":"${ [<description>encodeuricomponent[]] }$"}`
|
||||||
oncompletion=<<completion-createBag>>
|
oncompletion=<<completion-createBag>>
|
||||||
|
var-errorTiddler=<<errorTiddler>>
|
||||||
/>
|
/>
|
||||||
\end createBag
|
\end createBag
|
||||||
|
|
||||||
|
@ -35,12 +46,20 @@ title: MultiWikiServer Administration
|
||||||
<$edit-text tiddler="$:/state/NewBagDescription" tag="input" placeholder="(description)" class="mws-form-field-input"/>
|
<$edit-text tiddler="$:/state/NewBagDescription" tag="input" placeholder="(description)" class="mws-form-field-input"/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="mws-form-status">
|
||||||
|
<%if [[$:/state/NewBagError]get[text]else[]!match[]] %>
|
||||||
|
<div class="mws-form-error">
|
||||||
|
<$text text={{$:/state/NewBagError}}/>
|
||||||
|
</div>
|
||||||
|
<%endif%>
|
||||||
|
</div>
|
||||||
<div class="mws-form-buttons">
|
<div class="mws-form-buttons">
|
||||||
<$button class="mws-form-button">
|
<$button class="mws-form-button">
|
||||||
<$transclude
|
<$transclude
|
||||||
$variable="createBag"
|
$variable="createBag"
|
||||||
name={{$:/state/NewBagName}}
|
name={{$:/state/NewBagName}}
|
||||||
description={{$:/state/NewBagDescription}}
|
description={{$:/state/NewBagDescription}}
|
||||||
|
errorTiddler="$:/state/NewBagError"
|
||||||
/>
|
/>
|
||||||
Create Bag
|
Create Bag
|
||||||
</$button>
|
</$button>
|
||||||
|
@ -48,23 +67,26 @@ title: MultiWikiServer Administration
|
||||||
</form>
|
</form>
|
||||||
\end createBagButton
|
\end createBagButton
|
||||||
|
|
||||||
\procedure createRecipe(name,bag_names,description)
|
\procedure createRecipe(name,bag_names,description,errorTiddler)
|
||||||
\procedure completion-createRecipe()
|
\procedure completion-createRecipe()
|
||||||
\import [subfilter{$:/core/config/GlobalImportFilter}]
|
\import [subfilter{$:/core/config/GlobalImportFilter}]
|
||||||
<$action-log msg="In completion-createRecipe"/>
|
<%if [<error>match[]] %>
|
||||||
<$action-log/>
|
<$action-setfield $tiddler=<<errorTiddler>> text=""/>
|
||||||
|
<%else%>
|
||||||
|
<$action-setfield $tiddler=<<errorTiddler>> text=<<data>>/>
|
||||||
|
<%endif%>
|
||||||
\end completion-createRecipe
|
\end completion-createRecipe
|
||||||
\procedure emptyArray() []
|
\procedure emptyArray() []
|
||||||
\function createRecipeJson()
|
\function createRecipeJson()
|
||||||
[<bag_names>enlist-input[]] :reduce[<accumulator>!match[]else<emptyArray>jsonset<index>,<currentTiddler>]
|
[<bag_names>enlist-input[]] :reduce[<accumulator>!match[]else<emptyArray>jsonset<index>,<currentTiddler>]
|
||||||
\end createRecipeJson
|
\end createRecipeJson
|
||||||
<$action-log message="Sending" body=<<createRecipeJson>>/>
|
|
||||||
<$action-sendmessage
|
<$action-sendmessage
|
||||||
$message="tm-http-request"
|
$message="tm-http-request"
|
||||||
url=`/wiki/$(name)$/recipes/$(name)$`
|
url=`/wiki/$(name)$/recipes/$(name)$`
|
||||||
method="PUT"
|
method="PUT"
|
||||||
body=`{"bag_names":${ [<createRecipeJson>] }$,"description":"${ [<description>encodeuricomponent[]] }$"}`
|
body=`{"bag_names":${ [<createRecipeJson>] }$,"description":"${ [<description>encodeuricomponent[]] }$"}`
|
||||||
oncompletion=<<completion-createRecipe>>
|
oncompletion=<<completion-createRecipe>>
|
||||||
|
var-errorTiddler=<<errorTiddler>>
|
||||||
/>
|
/>
|
||||||
\end createRecipe
|
\end createRecipe
|
||||||
|
|
||||||
|
@ -94,6 +116,13 @@ title: MultiWikiServer Administration
|
||||||
<$edit-text tiddler="$:/state/NewRecipeDescription" tag="input" placeholder="(description)" class="mws-form-field-input"/>
|
<$edit-text tiddler="$:/state/NewRecipeDescription" tag="input" placeholder="(description)" class="mws-form-field-input"/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="mws-form-status">
|
||||||
|
<%if [[$:/state/NewRecipeError]get[text]else[]!match[]] %>
|
||||||
|
<div class="mws-form-error">
|
||||||
|
<$text text={{$:/state/NewRecipeError}}/>
|
||||||
|
</div>
|
||||||
|
<%endif%>
|
||||||
|
</div>
|
||||||
<div class="mws-form-buttons">
|
<div class="mws-form-buttons">
|
||||||
<$button class="mws-form-button">
|
<$button class="mws-form-button">
|
||||||
<$transclude
|
<$transclude
|
||||||
|
@ -101,6 +130,7 @@ title: MultiWikiServer Administration
|
||||||
name={{$:/state/NewRecipeName}}
|
name={{$:/state/NewRecipeName}}
|
||||||
bag_names={{$:/state/NewRecipeBagNames}}
|
bag_names={{$:/state/NewRecipeBagNames}}
|
||||||
description={{$:/state/NewRecipeDescription}}
|
description={{$:/state/NewRecipeDescription}}
|
||||||
|
errorTiddler="$:/state/NewRecipeError"
|
||||||
/>
|
/>
|
||||||
Create Recipe
|
Create Recipe
|
||||||
</$button>
|
</$button>
|
||||||
|
|
|
@ -12,6 +12,12 @@ Styles specific to the full screen layout
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
.mws-form-error {
|
||||||
|
border: 2px solid red;
|
||||||
|
padding: 1em;
|
||||||
|
margin: 1em;
|
||||||
|
}
|
||||||
|
|
||||||
.mws-wiki-card {
|
.mws-wiki-card {
|
||||||
display: flex;
|
display: flex;
|
||||||
margin: 1em 0;
|
margin: 1em 0;
|
||||||
|
|
Loading…
Reference in New Issue