Changed angular-1.0.2 to allow injection in resolve.
Dialog box for delete confirmation. Fixed forbidden view as it is not compatible with xhr
This commit is contained in:
parent
56f2892c0f
commit
b990158554
|
@ -1,19 +1,5 @@
|
||||||
import functools
|
|
||||||
import uuid
|
import uuid
|
||||||
from brewman.models.auth import User
|
from brewman.models.auth import User
|
||||||
from brewman.models.voucher import Voucher
|
|
||||||
|
|
||||||
class VoucherFactory(object):
|
|
||||||
__acl__ = []
|
|
||||||
|
|
||||||
def __init__(self, request):
|
|
||||||
self.request = request
|
|
||||||
|
|
||||||
def __getitem__(self, key):
|
|
||||||
voucher = Voucher.by_id(uuid.UUID(key))
|
|
||||||
voucher.__parent__ = self
|
|
||||||
voucher.__name__ = key
|
|
||||||
return voucher
|
|
||||||
|
|
||||||
def groupfinder(user_id, request):
|
def groupfinder(user_id, request):
|
||||||
if type(user_id) == str:
|
if type(user_id) == str:
|
||||||
|
|
|
@ -7193,7 +7193,7 @@ function $RouteProvider(){
|
||||||
|
|
||||||
forEach(next.resolve || {}, function(value, key) {
|
forEach(next.resolve || {}, function(value, key) {
|
||||||
keys.push(key);
|
keys.push(key);
|
||||||
values.push(isFunction(value) ? $injector.invoke(value) : $injector.get(value));
|
values.push(isString(value) ? $injector.get(value) : $injector.invoke(value));
|
||||||
});
|
});
|
||||||
if (isDefined(template = next.template)) {
|
if (isDefined(template = next.template)) {
|
||||||
} else if (isDefined(template = next.templateUrl)) {
|
} else if (isDefined(template = next.templateUrl)) {
|
||||||
|
|
|
@ -123,9 +123,9 @@
|
||||||
<button class="btn btn-danger" ng-click="resetVoucher(voucher.VoucherID)" ng-hide="voucher.Code == '(Auto)'">
|
<button class="btn btn-danger" ng-click="resetVoucher(voucher.VoucherID)" ng-hide="voucher.Code == '(Auto)'">
|
||||||
New Entry
|
New Entry
|
||||||
</button>
|
</button>
|
||||||
<button class="btn btn-danger" ng-click="delete()" ng-hide="voucher.Code == '(Auto)'"
|
<button class="btn btn-danger" ng-hide="voucher.Code == '(Auto)'" ng-disabled="preventAlteration(voucher)"
|
||||||
ng-disabled="preventAlteration(voucher)">
|
ng-confirm title="Delete Voucher" action-text="Are you sure? This cannot be undone."
|
||||||
Delete
|
action-button-text="Delete" action-function="delete()"> Delete
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="row-fluid">
|
<div class="row-fluid">
|
||||||
|
|
|
@ -74,9 +74,9 @@
|
||||||
<button class="btn btn-inverse" ng-click="post()" ng-hide="voucher.Code == '(Auto)'"
|
<button class="btn btn-inverse" ng-click="post()" ng-hide="voucher.Code == '(Auto)'"
|
||||||
ng-disabled="voucher.Posted || !perms['Post Vouchers']">{{voucher.Posted | posted}}
|
ng-disabled="voucher.Posted || !perms['Post Vouchers']">{{voucher.Posted | posted}}
|
||||||
</button>
|
</button>
|
||||||
<button class="btn btn-danger" ng-click="delete()" ng-hide="voucher.Code == '(Auto)'"
|
<button class="btn btn-danger" ng-hide="voucher.Code == '(Auto)'" ng-disabled="preventAlteration(voucher)"
|
||||||
ng-disabled="preventAlteration(voucher)">
|
ng-confirm title="Delete Voucher" action-text="Are you sure? This cannot be undone."
|
||||||
Delete
|
action-button-text="Delete" action-function="delete()"> Delete
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="row-fluid">
|
<div class="row-fluid">
|
||||||
|
|
|
@ -83,9 +83,9 @@
|
||||||
<button class="btn btn-inverse" ng-click="post()" ng-hide="voucher.Code == '(Auto)'"
|
<button class="btn btn-inverse" ng-click="post()" ng-hide="voucher.Code == '(Auto)'"
|
||||||
ng-disabled="voucher.Posted || !perms['Post Vouchers']">{{voucher.Posted | posted}}
|
ng-disabled="voucher.Posted || !perms['Post Vouchers']">{{voucher.Posted | posted}}
|
||||||
</button>
|
</button>
|
||||||
<button class="btn btn-danger" ng-click="delete()" ng-hide="voucher.Code == '(Auto)'"
|
<button class="btn btn-danger" ng-hide="voucher.Code == '(Auto)'" ng-disabled="preventAlteration(voucher)"
|
||||||
ng-disabled="preventAlteration(voucher)">
|
ng-confirm title="Delete Voucher" action-text="Are you sure? This cannot be undone."
|
||||||
Delete
|
action-button-text="Delete" action-function="delete()"> Delete
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="row-fluid">
|
<div class="row-fluid">
|
||||||
|
|
|
@ -98,9 +98,9 @@
|
||||||
<button class="btn btn-inverse" ng-click="post()" ng-hide="voucher.Code == '(Auto)'"
|
<button class="btn btn-inverse" ng-click="post()" ng-hide="voucher.Code == '(Auto)'"
|
||||||
ng-disabled="voucher.Posted || !perms['Post Vouchers']">{{voucher.Posted | posted}}
|
ng-disabled="voucher.Posted || !perms['Post Vouchers']">{{voucher.Posted | posted}}
|
||||||
</button>
|
</button>
|
||||||
<button class="btn btn-danger" ng-click="delete()" ng-hide="voucher.Code == '(Auto)'"
|
<button class="btn btn-danger" ng-hide="voucher.Code == '(Auto)'" ng-disabled="preventAlteration(voucher)"
|
||||||
ng-disabled="preventAlteration(voucher)">
|
ng-confirm title="Delete Voucher" action-text="Are you sure? This cannot be undone."
|
||||||
Delete
|
action-button-text="Delete" action-function="delete()"> Delete
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="row-fluid">
|
<div class="row-fluid">
|
||||||
|
|
|
@ -83,9 +83,9 @@
|
||||||
<button class="btn btn-inverse" ng-click="post()" ng-hide="voucher.Code == '(Auto)'"
|
<button class="btn btn-inverse" ng-click="post()" ng-hide="voucher.Code == '(Auto)'"
|
||||||
ng-disabled="voucher.Posted || !perms['Post Vouchers']">{{voucher.Posted | posted}}
|
ng-disabled="voucher.Posted || !perms['Post Vouchers']">{{voucher.Posted | posted}}
|
||||||
</button>
|
</button>
|
||||||
<button class="btn btn-danger" ng-click="delete()" ng-hide="voucher.Code == '(Auto)'"
|
<button class="btn btn-danger" ng-hide="voucher.Code == '(Auto)'" ng-disabled="preventAlteration(voucher)"
|
||||||
ng-disabled="preventAlteration(voucher)">
|
ng-confirm title="Delete Voucher" action-text="Are you sure? This cannot be undone."
|
||||||
Delete
|
action-button-text="Delete" action-function="delete()"> Delete
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="row-fluid">
|
<div class="row-fluid">
|
||||||
|
|
|
@ -127,6 +127,23 @@ overlord_directive.directive('fadey', function () {
|
||||||
return directiveDefinitionObject;
|
return directiveDefinitionObject;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
overlord_directive.directive('ngConfirm', function(modal) {
|
||||||
|
return {
|
||||||
|
restrict: 'A',
|
||||||
|
link: function postLink(scope, element, attrs) {
|
||||||
|
// Could have custom or boostrap modal options here
|
||||||
|
var options = {};
|
||||||
|
element.bind("click", function()
|
||||||
|
{
|
||||||
|
var actionButton = {text:attrs["actionButtonText"], click:attrs["actionFunction"], class:attrs['class']};
|
||||||
|
var cancelButton = {text:attrs["cancelButtonText"], click:attrs["cancelFunction"]};
|
||||||
|
modal.confirm(attrs["title"], attrs["actionText"], actionButton, cancelButton, scope, options);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
(function (angular) {
|
(function (angular) {
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -0,0 +1,85 @@
|
||||||
|
overlord_service.factory('modal', function ($http, $compile) {
|
||||||
|
var modal = {};
|
||||||
|
|
||||||
|
modal.get = function (create) {
|
||||||
|
if (!modal.dialog && create) {
|
||||||
|
modal.dialog = $('<div class="modal hide"></div>');
|
||||||
|
modal.dialog.appendTo('BODY');
|
||||||
|
}
|
||||||
|
return modal.dialog;
|
||||||
|
}
|
||||||
|
|
||||||
|
modal.compileAndRun = function (dialog, scope, options) {
|
||||||
|
$compile(dialog)(scope);
|
||||||
|
dialog.modal(options);
|
||||||
|
}
|
||||||
|
|
||||||
|
modal.alert = function (title, text, buttonText, alertFunction, scope, options) {
|
||||||
|
text = (text) ? text : "Alert";
|
||||||
|
buttonText = (buttonText) ? buttonText : "Ok";
|
||||||
|
var dialog = modal.get(true),
|
||||||
|
html = "";
|
||||||
|
if (title) {
|
||||||
|
html += "<div class=\"modal-header\"><h1>" + title + "</h1></div>";
|
||||||
|
}
|
||||||
|
html += "<div class=\"modal-body\">" + text + "</div>"
|
||||||
|
+ "<div class=\"modal-footer\">";
|
||||||
|
if (alertFunction) {
|
||||||
|
html += "<button class=\"btn\" ng-click=\"" + alertFunction + "\">" + buttonText + "</button>";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
html += "<button class=\"btn\">" + buttonText + "</button>";
|
||||||
|
}
|
||||||
|
html += "</div>";
|
||||||
|
dialog.html(html);
|
||||||
|
if (!alertFunction) {
|
||||||
|
dialog.find(".btn").click(function () {
|
||||||
|
modal.close();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
modal.compileAndRun(dialog, scope, options);
|
||||||
|
}
|
||||||
|
|
||||||
|
modal.confirm = function (title, actionText, actionButton, cancelButton, scope, options) {
|
||||||
|
actionText = (actionText) ? actionText : "Are you sure?";
|
||||||
|
actionButton.text = (actionButton.text) ? actionButton.text : "Ok";
|
||||||
|
cancelButton.text = (cancelButton.text) ? cancelButton.text : "Cancel";
|
||||||
|
|
||||||
|
var dialog = modal.get(true),
|
||||||
|
html = "";
|
||||||
|
if (title) {
|
||||||
|
html += "<div class=\"modal-header\"><h1>" + title + "</h1></div>";
|
||||||
|
}
|
||||||
|
html += "<div class=\"modal-body\">" + actionText + "</div>"
|
||||||
|
+ "<div class=\"modal-footer\">";
|
||||||
|
html += "<button id=\"action\" class=\"" + actionButton.class + "\">" + actionButton.text + "</button>";
|
||||||
|
html += "<button id=\"cancel\" class=\"btn btn-cancel\">" + cancelButton.text + "</button>";
|
||||||
|
html += "</div>";
|
||||||
|
dialog.html(html);
|
||||||
|
|
||||||
|
dialog.find("#action").click(function () {
|
||||||
|
if (actionButton.click) {
|
||||||
|
scope.$eval(actionButton.click);
|
||||||
|
}
|
||||||
|
modal.close();
|
||||||
|
});
|
||||||
|
dialog.find("#cancel").click(function () {
|
||||||
|
if (cancelButton.click) {
|
||||||
|
scope.$eval(cancelButton.click);
|
||||||
|
}
|
||||||
|
modal.close();
|
||||||
|
});
|
||||||
|
modal.compileAndRun(dialog, scope, options);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
modal.close = function () {
|
||||||
|
var popup = modal.get()
|
||||||
|
if (popup) {
|
||||||
|
popup.modal('hide');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return modal;
|
||||||
|
|
||||||
|
});
|
|
@ -163,7 +163,6 @@ function BaseCtrl($rootScope, $scope, Auth, $location) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
$rootScope.$on("$routeChangeStart", function (event, next, current) {
|
$rootScope.$on("$routeChangeStart", function (event, next, current) {
|
||||||
$rootScope.$broadcast('spinnerStart', 'route');
|
$rootScope.$broadcast('spinnerStart', 'route');
|
||||||
Auth.get(function (u, putResponseHeaders) {
|
Auth.get(function (u, putResponseHeaders) {
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
<script src="/script/angular_directive.js"> </script>
|
<script src="/script/angular_directive.js"> </script>
|
||||||
<script src="/script/angular_filter.js"> </script>
|
<script src="/script/angular_filter.js"> </script>
|
||||||
<script src="/script/angular_service.js"> </script>
|
<script src="/script/angular_service.js"> </script>
|
||||||
|
<script src="/script/modal-service.js"> </script>
|
||||||
<script src="/script/login.js"> </script>
|
<script src="/script/login.js"> </script>
|
||||||
|
|
||||||
<script src="/script/journal.js"> </script>
|
<script src="/script/journal.js"> </script>
|
||||||
|
@ -68,7 +69,7 @@
|
||||||
<link rel="apple-touch-icon-precomposed" href="/img/apple-touch-icon-57-precomposed.png">
|
<link rel="apple-touch-icon-precomposed" href="/img/apple-touch-icon-57-precomposed.png">
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body ng-controller="BaseCtrl">
|
<body ng-controller="BaseCtrl" ng-cloak>
|
||||||
|
|
||||||
<div class="navbar navbar-fixed-top">
|
<div class="navbar navbar-fixed-top">
|
||||||
<div class="navbar-inner">
|
<div class="navbar-inner">
|
||||||
|
|
|
@ -13,7 +13,7 @@ from pyramid.view import view_config
|
||||||
def home(request):
|
def home(request):
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
@view_config(context=HTTPForbidden, renderer='brewman:templates/angular_base.mako', xhr=False)
|
@view_config(context=HTTPForbidden, renderer='brewman:templates/angular_base.mako')
|
||||||
def forbidden(request):
|
def forbidden(request):
|
||||||
if 'X-Requested-With' in request.headers and request.headers['X-Requested-With'] == 'XMLHttpRequest':
|
if 'X-Requested-With' in request.headers and request.headers['X-Requested-With'] == 'XMLHttpRequest':
|
||||||
response = Response("Forbidden")
|
response = Response("Forbidden")
|
||||||
|
|
Loading…
Reference in New Issue