Merge pull request #52 from alberanid/master

notifications for main actions
This commit is contained in:
Davide Alberani 2015-04-21 23:35:40 +02:00
commit b5ba71f7c5
5 changed files with 80 additions and 10 deletions

View file

@ -1,5 +1,6 @@
<!-- show details of an Event -->
<div class="container">
<div eventman-message="eventman-message" control="message" ng-class="{'eventman-message': true, clearfix: true, alert: true, 'alert-success': !dControl.isError, 'alert-danger': dControl.isError}"></div>
<div class="container">
<div class="row">
<div class="col-md-7 col-xs-7 vcenter">

View file

@ -58,6 +58,7 @@ eventManControllers.controller('EventDetailsCtrl', ['$scope', 'Event', 'Person',
$scope.personsOrderProp = 'name';
$scope.eventsOrderProp = '-begin-date';
$scope.countAttendees = 0;
$scope.message = {};
$scope.customFields = Setting.query({setting: 'person_custom_field',
in_event_details: true});
@ -118,6 +119,9 @@ eventManControllers.controller('EventDetailsCtrl', ['$scope', 'Event', 'Person',
$scope.allPersons = Person.all();
}
$scope.newPerson = {};
// XXX: must be converted in a i18n-able form.
var msg = '' + person_data.name + ' ' + person_data.surname + ' successfully added to event ' + $scope.event.title;
$scope.showMessage({message: msg});
});
});
$scope.query = '';
@ -150,6 +154,16 @@ eventManControllers.controller('EventDetailsCtrl', ['$scope', 'Event', 'Person',
if (callback) {
callback(data);
}
if (key === 'attended') {
var msg = {};
if (value) {
msg.message = '' + person.name + ' ' + person.surname + ' successfully added to event ' + $scope.event.title;
} else {
msg.message = '' + person.name + ' ' + person.surname + ' successfully removed from event ' + $scope.event.title;
msg.isError = true;
}
$scope.showMessage(msg);
}
});
};
@ -168,6 +182,10 @@ eventManControllers.controller('EventDetailsCtrl', ['$scope', 'Event', 'Person',
$scope.allPersons = Person.all();
});
};
$scope.showMessage = function(cfg) {
$scope.message.show(cfg);
};
}]
);

View file

@ -39,3 +39,32 @@ eventManApp.directive('resetFocus', function () {
};
});
eventManApp.directive('eventmanMessage', ['$timeout',
function($timeout) {
function link(scope, element, attrs) {
scope.dControl = scope.control || {};
scope.dControl.isVisible = false;
scope.dControl.show = function(cfg) {
cfg = cfg || {};
scope.dControl.isVisible = true;
scope.dControl.message = cfg.message;
scope.dControl.isError = cfg.isError;
$timeout(function () {
scope.dControl.isVisible = false;
}, cfg.timeout || 2000);
};
};
return {
scope: {
control: '='
},
link: link,
replace: true,
template: '<div ng-if="dControl.isVisible">{{dControl.message}}</div>'
};
}]
);

View file

@ -1,15 +1,27 @@
<!-- show the list of Persons -->
<div class="container">
<h1>{{'Persons' | translate}}
<button ng-click="$state.go('person.new')" class="btn btn-success">
<span class="glyphicon glyphicon-plus-sign"></span>
{{'Add person' | translate}}
</button>
<button ng-click="$state.go('import.persons')" class="btn btn-success">
<span class="glyphicon glyphicon-plus-sign"></span>
{{'Import persons' | translate}}
</button>
</h1>
<div class="container">
<div class="row">
<div class="col-md-7 col-xs-7 vcenter">
<h1>{{'Persons' | translate}}
<button ng-click="$state.go('person.new')" class="btn btn-success">
<span class="glyphicon glyphicon-plus-sign"></span>
{{'Add person' | translate}}
</button>
<button ng-click="$state.go('import.persons')" class="btn btn-success">
<span class="glyphicon glyphicon-plus-sign"></span>
{{'Import persons' | translate}}
</button>
</h1>
</div><!--
--><div class="col-md-5 col-xs-5 vcenter">
<div class="row">
<div class="col-md-6">
<h2><div class="label label-info vcenter">{{'Persons:' | translate}} {{persons.length || 0}}</div></h2>
</div>
</div>
</div>
</div>
<div class="panel panel-primary table-striped top5">
<div class="panel-heading">{{'Persons' | translate}}</div>
<div class="panel-body">

View file

@ -19,4 +19,14 @@ body { padding-top: 70px; }
float: none;
}
.eventman-message {
position: fixed;
top: 2%;
width: 40%;
left: 30%;
text-align: center;
display: inline-block;
z-index: 10000;
}
/* .row { display: table; } */