fixes #139: quick add using the custom form

This commit is contained in:
Davide Alberani 2016-07-02 00:05:50 +02:00
parent b2d2b397d5
commit fee4458be1
3 changed files with 56 additions and 48 deletions

View file

@ -9,6 +9,11 @@
<span class="fa fa-pencil-square-o vcenter"></span>
{{'Edit' | translate}}
</button>
&nbsp;
<button ng-if="event._id" ng-click="openQuickAddTicket()" class="btn btn-success">
<span class="fa fa-user-plus vcenter"></span>
{{'Quick add ticket' | translate}}
</button>
</h1>
</div><!--
--><div class="col-md-5 col-xs-5 vcenter">
@ -77,40 +82,6 @@
</div>
<div class="col-md-4">
<div class="panel panel-info table-striped top5">
<div class="panel-heading">{{'Quick add' | translate}}</div>
<div class="panel-body">
<form>
<div class="input-group input-group-sm">
<span class="input-group-addon min70-compact">{{'Name' | translate}}</span>
<input type="text" class="form-control" placeholder="{{'Name' | translate}}" ng-model="newPerson.name" ng-required="1">
</div>
<div class="input-group input-group-sm top5">
<span class="input-group-addon min70-compact">{{'Surname' | translate}}</span>
<input type="text" class="form-control" placeholder="{{'Surname' | translate}}" ng-model="newPerson.surname">
</div>
<div class="input-group top5">
<span class="input-group-addon min70-compact">{{'Email' | translate}}</span>
<input type="email" name="email" class="form-control" placeholder="{{'name.surname@example.com' | translate}}" ng-model="newPerson.email">
</div>
<div class="input-group top5">
<span class="input-group-addon min70-compact">{{'Company' | translate}}</span>
<input name="company" class="form-control" placeholder="{{'Acme Corporation' | translate}}" ng-model="newPerson.company">
</div>
<div class="input-group top5">
<span class="input-group-addon min70-compact">{{'Job' | translate}}</span>
<input name="job_title" class="form-control" placeholder="{{'Evil Ruler' | translate}}" ng-model="newPerson.job_title">
</div>
<button reset-focus ng-disabled="!(newPerson.name && newPerson.surname)" ng-click="fastAddAttendee(newPerson, true)" class="btn btn-success top5">
<span class="fa fa-plus-circle vcenter"></span>
{{'Add' | translate}}
</button>
</form>
</div>
</div>
<div class="panel panel-info top5">
<div class="panel-heading">{{'Unregistered persons' | translate}}</div>
<div class="panel-body small-table">

View file

@ -51,23 +51,23 @@ eventManControllers.controller('DatetimePickerCtrl', ['$scope',
/* Controller for modals. */
eventManControllers.controller('ModalConfirmInstanceCtrl', ['$scope', '$modalInstance', 'message',
function ($scope, $modalInstance, message) {
eventManControllers.controller('ModalConfirmInstanceCtrl', ['$scope', '$uibModalInstance', 'message',
function ($scope, $uibModalInstance, message) {
$scope.message = message;
$scope.ok = function () {
$modalInstance.close($scope);
$uibModalInstance.close($scope);
};
$scope.cancel = function () {
$modalInstance.dismiss('cancel');
$uibModalInstance.dismiss('cancel');
};
}]
);
eventManControllers.controller('EventsListCtrl', ['$scope', 'Event', '$modal', '$log', '$translate', '$rootScope',
function ($scope, Event, $modal, $log, $translate, $rootScope) {
eventManControllers.controller('EventsListCtrl', ['$scope', 'Event', '$uibModal', '$log', '$translate', '$rootScope',
function ($scope, Event, $uibModal, $log, $translate, $rootScope) {
$scope.events = Event.all();
$scope.personsOrderProp = 'name';
$scope.eventsOrderProp = "-begin_date";
@ -80,7 +80,7 @@ eventManControllers.controller('EventsListCtrl', ['$scope', 'Event', '$modal', '
});
$scope.remove = function(_id) {
var modalInstance = $modal.open({
var modalInstance = $uibModal.open({
scope: $scope,
templateUrl: 'modal-confirm-action.html',
controller: 'ModalConfirmInstanceCtrl',
@ -99,8 +99,8 @@ eventManControllers.controller('EventsListCtrl', ['$scope', 'Event', '$modal', '
);
eventManControllers.controller('EventDetailsCtrl', ['$scope', '$state', 'Event', 'Person', 'EventUpdates', '$stateParams', 'Setting', '$log', '$translate', '$rootScope', 'easyFormSteWayConfig',
function ($scope, $state, Event, Person, EventUpdates, $stateParams, Setting, $log, $translate, $rootScope, easyFormSteWayConfig) {
eventManControllers.controller('EventDetailsCtrl', ['$scope', '$state', 'Event', 'Person', 'EventUpdates', '$stateParams', 'Setting', '$log', '$translate', '$rootScope', 'easyFormSteWayConfig', '$uibModal',
function ($scope, $state, Event, Person, EventUpdates, $stateParams, Setting, $log, $translate, $rootScope, easyFormSteWayConfig, $uibModal) {
$scope.personsOrder = ["name", "surname"];
$scope.countAttendees = 0;
$scope.message = {};
@ -265,6 +265,16 @@ eventManControllers.controller('EventDetailsCtrl', ['$scope', '$state', 'Event',
}
};
$scope.openQuickAddTicket = function(_id) {
var modalInstance = $uibModal.open({
templateUrl: 'modal-quick-add-ticket.html',
controller: 'EventTicketsCtrl'
});
modalInstance.result.then(function(x) {
$scope.event = Event.get($stateParams);
});
};
$scope.addRegisteredPerson = function(person) {
$scope.fastAddAttendee(person, true);
};
@ -425,7 +435,11 @@ eventManControllers.controller('EventTicketsCtrl', ['$scope', '$state', 'Event',
person._id = $state.params.id; // that's the id of the event, not the person.
EventTicket.add(person, function(ticket) {
$log.debug(ticket);
$state.go('event.ticket.edit', {id: $scope.event._id, ticket_id: ticket._id});
if (!$state.is('event.tickets')) {
$state.go('event.ticket.edit', {id: $scope.event._id, ticket_id: ticket._id});
} else if ($scope.$close) {
$scope.$close();
}
});
});
};
@ -464,14 +478,18 @@ eventManControllers.controller('EventTicketsCtrl', ['$scope', '$state', 'Event',
};
$scope.cancelForm = function() {
$state.go('events');
if (!$state.is('event.tickets')) {
$state.go('events');
} else if ($scope.$close) {
$scope.$close();
}
};
}]
);
eventManControllers.controller('PersonsListCtrl', ['$scope', 'Person', 'Setting', '$modal', '$translate', '$rootScope',
function ($scope, Person, Setting, $modal, $translate, $rootScope) {
eventManControllers.controller('PersonsListCtrl', ['$scope', 'Person', 'Setting', '$uibModal', '$translate', '$rootScope',
function ($scope, Person, Setting, $uibModal, $translate, $rootScope) {
$scope.persons = Person.all();
$scope.personsOrder = ["name", "surname"];
$scope.customFields = Setting.query({setting: 'person_custom_field',
@ -511,7 +529,7 @@ eventManControllers.controller('PersonsListCtrl', ['$scope', 'Person', 'Setting'
};
$scope.remove = function(_id) {
var modalInstance = $modal.open({
var modalInstance = $uibModal.open({
scope: $scope,
templateUrl: 'modal-confirm-action.html',
controller: 'ModalConfirmInstanceCtrl',

View file

@ -0,0 +1,19 @@
<div>
<div class="modal-header">
<h3>{{'Quick add a ticket' | translate}}</h3>
</div>
<div class="modal-body" ng-cloak>
<eda-easy-form-viewer
eda-easy-form-viewer-data-model="formData"
eda-easy-form-viewer-easy-form-generator-fields-model="formSchema"
eda-easy-form-viewer-submit-form-event="submitForm(dataModelSubmitted)"
eda-easy-form-viewer-cancel-form-event="cancelForm()">
</eda-easy-form-viewer>
</div>
<div class="modal-footer">
</div>
</div>