Skip to content

Commit

Permalink
Creation element placeholders and error feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
Victorma committed May 30, 2017
1 parent 840798f commit 0575c64
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 6 deletions.
4 changes: 4 additions & 0 deletions app/public/js/controllers/activities.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,13 +160,16 @@ angular.module('activitiesApp', ['ngStorage', 'services'])
};

$scope.createActivity = function () {
$scope.activityCreatedError = '';
if (!$scope.activity.gameId && !QueryParams.getQueryParam('game')) {
// It's necessary to pick a game
$scope.activityCreatedError = 'Please, select a game.';
return;
}

if (!$scope.activity.classId && !QueryParams.getQueryParam('class')) {
// It's necessary to pick a class
$scope.activityCreatedError = 'Please, select a class.';
return;
}

Expand Down Expand Up @@ -224,6 +227,7 @@ angular.module('activitiesApp', ['ngStorage', 'services'])
};

$scope.activityOpenedError = '';
$scope.activityCreatedError = '';
$scope.deleteActivity = function (activityObj) {
if (activityObj) {
$http.delete(CONSTANTS.PROXY + '/activities/' + activityObj._id).success(function () {
Expand Down
3 changes: 2 additions & 1 deletion app/views/classActivity.jade
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,14 @@ block content
.panel-heading Create a new Activity
.panel-body
label Activity title:
input.form-control(type='text' ng-model='activity.name')
input.form-control(placeholder='New Activity' type='text' ng-model='activity.name')
label Game:
select.form-control(ng-controller='AppCtrl' ng-model='activity.gameId')
option(ng-repeat='game in games' value='{{ game._id }}') {{ game.title }}
a.btn.btn-primary(type='button', ng-click='createActivity()')
span.glyphicon.glyphicon-plus.right10
| New activity
p.btn-danger {{activityCreatedError}}
p.btn-danger {{activityOpenedError}}
table.table.table-hover
thead
Expand Down
5 changes: 3 additions & 2 deletions app/views/gameActivity.jade
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,15 @@ block content
.panel-heading Create a new Activity
.panel-body
label Activity title:
input.form-control(type='text' ng-model='activity.name')
input.form-control(placeholder='New Activity' type='text' ng-model='activity.name')
label Class:
select.form-control(ng-controller='AppCtrl' ng-model='activity.classId')
option(ng-repeat='class in classes' value='{{ class._id }}') {{ class.name }}
a.btn.btn-primary(type='button', ng-click='createActivity()')
span.glyphicon.glyphicon-plus.right10
| New activity
p.btn-danger {{activityOpenedError}}
p.btn-danger {{activityCreatedError}}
p.btn-danger {{activityOpenedError}}
table.table.table-hover
thead
tr
Expand Down
7 changes: 4 additions & 3 deletions app/views/home.jade
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ block content
.panel-heading Create a new Activity
.panel-body
label Activity name:
input.form-control(type='text' ng-model='activity.name')
input.form-control(placeholder='New Activity' type='text' ng-model='activity.name')
label Game:
select.form-control(ng-model='activity.gameId')
option(ng-repeat='game in games' value='{{ game._id }}') {{ game.title }}
Expand All @@ -36,6 +36,7 @@ block content
a.btn.btn-primary(type='button', ng-click='createActivity()')
span.glyphicon.glyphicon-plus.right10
| New activity
p.btn-danger {{activityCreatedError}}
p.btn-danger {{activityOpenedError}}
table.table.table-hover
thead
Expand Down Expand Up @@ -73,7 +74,7 @@ block content
.panel-heading Create a new Game
.panel-body
label Game title:
input.form-control(type='text' ng-model='game.gameTitle')
input.form-control(placeholder='New Game' type='text' ng-model='game.gameTitle')
a.btn.btn-primary(align='center' type='button', ng-click='createGame()')
span.glyphicon.glyphicon-plus.right10
| New game
Expand Down Expand Up @@ -102,7 +103,7 @@ block content
.panel-heading Create a new Class
.panel-body
label Class title:
input.form-control(type='text' ng-model='class.name')
input.form-control(placeholder='New Class' type='text' ng-model='class.name')
a.btn.btn-primary(type='button', ng-click='createClass()')
span.glyphicon.glyphicon-plus.right10
| New class
Expand Down

0 comments on commit 0575c64

Please sign in to comment.