Skip to content

Commit 7c14bed

Browse files
committed
feat(uibootstrap-modal): add basic modal service and template when using uibootstrap
Changes: (only if ui-bootstrap is selected) - add `client/components/modal` folder - modal folder contains service, markup template, and stylesheet - modal service is intended to be extended, comes with `Modal.confirm.delete()` method - admin and main page will both use `Modal.confirm.delete()` Todo: - review code for cleanliness and correctness - possibly extend the modal service to include a basic alert class? - write test for `Modal` service?
1 parent c9f80bc commit 7c14bed

16 files changed

+277
-14
lines changed

app/templates/client/app/admin(auth)/admin(html).html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<li class="list-group-item" ng-repeat="user in users">
77
<strong>{{user.name}}</strong><br>
88
<span class="text-muted">{{user.email}}</span>
9-
<a ng-click="delete(user)" class="trash"><span class="glyphicon glyphicon-trash pull-right"></span></a>
9+
<a ng-click="delete(<% if(filters.uibootstrap) { %>user.name + ' (' + user.email + ')', <% } %>user)" class="trash"><span class="glyphicon glyphicon-trash pull-right"></span></a>
1010
</li>
1111
</ul>
1212
</div>

app/templates/client/app/admin(auth)/admin(jade).jade

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@ div(ng-include='"components/navbar/navbar.html"')
77
strong {{user.name}}
88
br
99
span.text-muted {{user.email}}
10-
a.trash(ng-click='delete(user)')
10+
a.trash(ng-click='delete(<% if(filters.uibootstrap) { %>user.name + " (" + user.email + ")", <% } %>user)')
1111
span.glyphicon.glyphicon-trash.pull-right
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
'use strict'
22

33
angular.module '<%= scriptAppName %>'
4-
.controller 'AdminCtrl', ($scope, $http, Auth, User) ->
4+
.controller 'AdminCtrl', ($scope, $http, Auth, User<% if(filters.uibootstrap) { %>, Modal<% } %>) ->
55

66
# Use the User $resource to fetch all users
77
$scope.users = User.query()
88

9-
$scope.delete = (user) ->
9+
$scope.delete = <% if(filters.uibootstrap) { %>Modal.confirm.delete <% } %>(user) ->
1010
User.remove id: user._id
1111
angular.forEach $scope.users, (u, i) ->
1212
$scope.users.splice i, 1 if u is user
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
'use strict';
22

33
angular.module('<%= scriptAppName %>')
4-
.controller('AdminCtrl', function ($scope, $http, Auth, User) {
4+
.controller('AdminCtrl', function ($scope, $http, Auth, User<% if(filters.uibootstrap) { %>, Modal<% } %>) {
55

66
// Use the User $resource to fetch all users
77
$scope.users = User.query();
88

9-
$scope.delete = function(user) {
9+
$scope.delete = <% if(filters.uibootstrap) { %>Modal.confirm.delete(<% } %>function(user) {
1010
User.remove({ id: user._id });
1111
angular.forEach($scope.users, function(u, i) {
1212
if (u === user) {
1313
$scope.users.splice(i, 1);
1414
}
1515
});
16-
};
16+
}<% if(filters.uibootstrap) { %>)<% } %>;
1717
});

app/templates/client/app/main/main(html).html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ <h1>'Allo, 'Allo!</h1>
1313
<div class="col-lg-12">
1414
<h1 class="page-header">Features:</h1>
1515
<ul class="nav nav-tabs nav-stacked col-md-4 col-lg-4 col-sm-6" ng-repeat="thing in awesomeThings">
16-
<li><a href="#" tooltip="{{thing.info}}">{{thing.name}}<% if(filters.socketio) { %><button type="button" class="close" ng-click="deleteThing(thing)">&times;</button><% } %></a></li>
16+
<li><a href="#" tooltip="{{thing.info}}">{{thing.name}}<% if(filters.socketio) { %><button type="button" class="close" ng-click="deleteThing(<% if(filters.uibootstrap) { %>thing.name, <% } %>thing)">&times;</button><% } %></a></li>
1717
</ul>
1818
</div>
1919
</div><% if(filters.socketio) { %>

app/templates/client/app/main/main(jade).jade

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ header#banner.hero-unit
1414
li
1515
a(href='#', tooltip='{{thing.info}}')
1616
| {{thing.name}}<% if(filters.socketio) { %>
17-
button.close(type='button', ng-click='deleteThing(thing)') ×<% } %><% if(filters.socketio) { %>
17+
button.close(type='button', ng-click='deleteThing(<% if(filters.uibootstrap) { %>thing.name, <% } %>thing)') ×<% } %><% if(filters.socketio) { %>
1818

1919
form.thing-form
2020
label Syncs in realtime across clients

app/templates/client/app/main/main.controller(coffee).coffee

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use strict'
22

33
angular.module '<%= scriptAppName %>'
4-
.controller 'MainCtrl', ($scope, $http<% if(filters.socketio) { %>, socket<% } %>) ->
4+
.controller 'MainCtrl', ($scope, $http<% if(filters.socketio) { %>, socket<% } %><% if(filters.uibootstrap && filters.mongoose) { %>, Modal<% } %>) ->
55
$scope.awesomeThings = []
66

77
$http.get('/api/things').success (awesomeThings) ->
@@ -15,7 +15,7 @@ angular.module '<%= scriptAppName %>'
1515

1616
$scope.newThing = ''
1717

18-
$scope.deleteThing = (thing) ->
18+
$scope.deleteThing = <% if(filters.uibootstrap) { %>Modal.confirm.delete <% } %>(thing) ->
1919
$http.delete '/api/things/' + thing._id<% } %><% if(filters.socketio) { %>
2020

2121
$scope.$on '$destroy', ->

app/templates/client/app/main/main.controller(js).js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use strict';
22

33
angular.module('<%= scriptAppName %>')
4-
.controller('MainCtrl', function ($scope, $http<% if(filters.socketio) { %>, socket<% } %>) {
4+
.controller('MainCtrl', function ($scope, $http<% if(filters.socketio) { %>, socket<% } %><% if(filters.uibootstrap && filters.mongoose) { %>, Modal<% } %>) {
55
$scope.awesomeThings = [];
66

77
$http.get('/api/things').success(function(awesomeThings) {
@@ -17,9 +17,9 @@ angular.module('<%= scriptAppName %>')
1717
$scope.newThing = '';
1818
};
1919

20-
$scope.deleteThing = function(thing) {
20+
$scope.deleteThing = <% if(filters.uibootstrap) { %>Modal.confirm.delete(<% } %>function(thing) {
2121
$http.delete('/api/things/' + thing._id);
22-
};<% } %><% if(filters.socketio) { %>
22+
}<% if(filters.uibootstrap) { %>)<% } %>;<% } %><% if(filters.socketio) { %>
2323

2424
$scope.$on('$destroy', function () {
2525
socket.unsyncUpdates('thing');
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
.modal-primary .modal-header,
2+
.modal-info .modal-header,
3+
.modal-success .modal-header,
4+
.modal-warning .modal-header,
5+
.modal-danger .modal-header {
6+
color: #fff;
7+
border-radius: 5px 5px 0 0;
8+
}
9+
.modal-primary .modal-header {
10+
background: #428bca;
11+
}
12+
.modal-info .modal-header {
13+
background: #5bc0de;
14+
}
15+
.modal-success .modal-header {
16+
background: #5cb85c;
17+
}
18+
.modal-warning .modal-header {
19+
background: #f0ad4e;
20+
}
21+
.modal-danger .modal-header {
22+
background: #d9534f;
23+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<div class="modal-header">
2+
<button ng-if="modal.dismissable" type="button" ng-click="$dismiss()" class="close">&times;</button>
3+
<h4 ng-if="modal.title" ng-bind="modal.title" class="modal-title"></h4>
4+
</div>
5+
<div class="modal-body">
6+
<p ng-if="modal.text" ng-bind="modal.text"></p>
7+
<div ng-if="modal.html" ng-bind-html="modal.html"></div>
8+
</div>
9+
<div class="modal-footer">
10+
<button ng-repeat="button in modal.buttons" ng-class="button.classes" ng-click="button.click($event)" ng-bind="button.text" class="btn"></button>
11+
</div>

0 commit comments

Comments
 (0)