-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #220 from camptocamp/GSC2CGIF-65-readonly-actions
Show item actions in readonly form
- Loading branch information
Showing
4 changed files
with
51 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<tal:loop tal:condition="exists: actions" tal:repeat="action actions"> | ||
<a tal:condition="not action.method()" | ||
class="btn btn-default c2cgeoform-item-action ${action.name()} ${action.css_class()}" | ||
href="${action.url()}"> | ||
<span tal:omit-tag="not action.icon()" class="${action.icon()}"></span> | ||
${action.label()}</a> | ||
<a tal:condition="action.method()" | ||
class="btn btn-default c2cgeoform-item-action c2cgeoform-action-ajax ${action.name()} ${action.css_class()}" | ||
href="#" | ||
data-url="${action.url()}" | ||
data-method="${action.method()}" | ||
data-confirmation="${action.confirmation()}"> | ||
<span tal:omit-tag="not action.icon()" class="${action.icon()}"></span> | ||
${action.label()}</a> | ||
</tal:loop> | ||
|
||
<script type="text/javascript"> | ||
$(function () { | ||
$('#${formid} a.c2cgeoform-action-ajax').on('click', function(e) { | ||
var execute = function() { | ||
$.ajax({ | ||
url: $(this).data('url'), | ||
type: $(this).data('method'), | ||
success: function(data) { | ||
window.location = data.redirect; | ||
} | ||
}); | ||
}.bind(this); | ||
|
||
if ($(this).data('confirmation')) { | ||
if (window.confirm($(this).data('confirmation'))) { | ||
execute(); | ||
} | ||
} else { | ||
execute(); | ||
} | ||
|
||
return false; | ||
}); | ||
}); | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters