Skip to content

Commit

Permalink
mod_admin: Flushed out ability to save [object, predicate] pairs when…
Browse files Browse the repository at this point in the history
… creating new rsc using the dialog_new_rsc action.

Example Usage:

{% button text="New Topic"
    action={ dialog_new_rsc
             cat='topic'
             tabs_enabled = ["new"]
             nocatselect = "true"
             redirect = `topics`
             objects = [[m.acl.user, `author`]]
    }
%}
  • Loading branch information
Jeff Bell committed May 28, 2015
1 parent 85baf0a commit 99a4588
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
8 changes: 5 additions & 3 deletions modules/mod_admin/actions/action_admin_dialog_new_rsc.erl
Expand Up @@ -38,14 +38,15 @@ render_action(TriggerId, TargetId, Args, Context) ->
Predicate = proplists:get_value(predicate, Args),
Callback = proplists:get_value(callback, Args),
Actions = proplists:get_all_values(action, Args),
Postback = {new_rsc_dialog, Title, Cat, NoCatSelect, TabsEnabled, Redirect, SubjectId, Predicate, Callback, Actions},
Objects = proplists:get_value(objects, Args),
Postback = {new_rsc_dialog, Title, Cat, NoCatSelect, TabsEnabled, Redirect, SubjectId, Predicate, Callback, Actions, Objects},
{PostbackMsgJS, _PickledPostback} = z_render:make_postback(Postback, click, TriggerId, TargetId, ?MODULE, Context),
{PostbackMsgJS, Context}.


%% @doc Fill the dialog with the new page form. The form will be posted back to this module.
%% @spec event(Event, Context1) -> Context2
event(#postback{message={new_rsc_dialog, Title, Cat, NoCatSelect, TabsEnabled, Redirect, SubjectId, Predicate, Callback, Actions}}, Context) ->
event(#postback{message={new_rsc_dialog, Title, Cat, NoCatSelect, TabsEnabled, Redirect, SubjectId, Predicate, Callback, Actions, Objects}}, Context) ->
CatId = case Cat of
[] -> undefined;
undefined -> undefined;
Expand All @@ -68,7 +69,8 @@ event(#postback{message={new_rsc_dialog, Title, Cat, NoCatSelect, TabsEnabled, R
{catname, CatName},
{callback, Callback},
{catname, CatName},
{actions, Actions}
{actions, Actions},
{objects, Objects}
],
z_render:dialog(?__("Make a new page", Context), "_action_dialog_new_rsc.tpl", Vars, Context);

Expand Down
5 changes: 3 additions & 2 deletions modules/mod_admin/templates/_action_dialog_new_rsc_tab.tpl
Expand Up @@ -5,8 +5,9 @@
subject_id=subject_id
predicate=predicate
redirect=redirect
actions=actions
callback=callback
actions=actions
callback=callback
objects=objects
}
delegate=delegate
%}
Expand Down

0 comments on commit 99a4588

Please sign in to comment.