Skip to content

Commit

Permalink
mod_admin: misc fixes for the connect/disconnect dialog (0.x) (#3269)
Browse files Browse the repository at this point in the history
  • Loading branch information
mworrell committed Jan 20, 2023
1 parent 1ea3ea6 commit 29d5af3
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 8 deletions.
15 changes: 13 additions & 2 deletions modules/mod_admin/mod_admin.erl
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,16 @@ event(#postback_notify{message="admin-insert-block"}, Context) ->
event(#postback_notify{message="feedback", trigger=Trigger, target=TargetId}, Context)
when Trigger =:= "dialog-new-rsc-tab"; Trigger =:= "dialog-connect-find" ->
% Find pages matching the search criteria.
CreatorId = z_convert:to_integer(z_context:get_q(find_creator_id, Context)),
CreatorId = case z_convert:to_integer(z_context:get_q(find_creator_id, Context)) of
undefined ->
case z_context:get_q(find_cg, Context) of
<<"me">> -> z_acl:user(Context);
"me" -> z_acl:user(Context);
_ -> undefined
end;
CrId ->
CrId
end,
SubjectId = z_convert:to_integer(z_context:get_q(subject_id, Context)),
ObjectId = z_convert:to_integer(z_context:get_q(object_id, Context)),
Predicate = z_convert:to_binary(z_context:get_q(predicate, Context, "")),
Expand Down Expand Up @@ -250,9 +259,11 @@ event(#postback_notify{message="feedback", trigger=Trigger, target=TargetId}, Co
end},
{is_zlink, z_convert:to_bool( z_context:get_q(is_zlink, Context) )}
] ++ case z_context:get_q(find_cg, Context) of
undefined -> [];
<<>> -> [];
"" -> [];
undefined -> [];
"me" -> [];
<<"me">> -> [];
CgId -> [ {content_group, m_rsc:rid(CgId, Context)}]
end,
case Trigger of
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@
action=action
actions=actions
autoclose=autoclose
is_connect_toggle=not is_zmedia
}
}
%}
Expand Down
31 changes: 25 additions & 6 deletions modules/mod_base/lib/js/apps/zotonic-1.0.js
Original file line number Diff line number Diff line change
Expand Up @@ -1944,11 +1944,28 @@ function z_transport_form(qmsg)
setTimeout(function() { timedOut = true; cb(); }, opts.timeout);
}

zmsgInput = $('<input />')
.attr('type', 'hidden')
.attr('name', 'z_msg')
.attr('value', ubf.encode(qmsg.msg))
.prependTo(form)[0];
let extraInputs = [];

extraInputs.push(
$('<input />')
.attr('type', 'hidden')
.attr('name', 'z_msg')
.attr('value', ubf.encode(qmsg.msg))
.prependTo(form)[0]);

// Prepend all unchecked checkboxes as empty hidden input values
$(form).find('input[type="checkbox"]:not(:checked):not(.nosubmit)').each(
function() {
const name = $(this).attr('name');
if (name) {
extraInputs.push(
$('<input />')
.attr('type', 'hidden')
.attr('name', name)
.attr('value', '')
.prependTo(form)[0]);
}
});

try {
// add iframe to doc and submit the form
Expand All @@ -1968,7 +1985,9 @@ function z_transport_form(qmsg)
} else {
$form.removeAttr('target');
}
$(zmsgInput).remove();
for (let n in extraInputs) {
$(n).remove();
}
}
}, 10);

Expand Down

0 comments on commit 29d5af3

Please sign in to comment.