Tasks: More Improvements

This commit is contained in:
Sagi Dayan 2015-07-25 18:25:45 +03:00
parent fcaa93a713
commit 35df7cd3e3
3 changed files with 59 additions and 26 deletions

View file

@ -1,7 +1,8 @@
angular.module('SeHub') angular.module('SeHub')
.controller('taskController', ['$scope', '$rootScope', 'dataService', 'apiService', .controller('taskController', ['$scope', '$rootScope', 'dataService', 'apiService',
'$cookies', '$location', '$routeParams', '$cookies', '$location', '$routeParams', '$mdDialog',
function($scope, $rootScope, dataService, apiService, $cookies, $location, $routeParams) {
function($scope, $rootScope, dataService, apiService, $cookies, $location, $routeParams, $mdDialog) {
var taskId = $routeParams.taskId; var taskId = $routeParams.taskId;
var submitterId = $routeParams.submitterId; var submitterId = $routeParams.submitterId;
@ -50,6 +51,30 @@ angular.module('SeHub')
}; };
} }
function validateComponents() {
for (var i = 0; i < $scope.task.components.length; i++) {
if ($scope.task.components[i].isMandatory && (!$scope.task.components[i].value || $scope.task.components[i].value == ''))
return false;
}
return true;
}
$scope.submitTask = function(event) { //Dialog will pop-up if not all mandatory fields are filled
if (validateComponents()) {
alert('All Shit Are Filled');
return;
}
$mdDialog.show(
$mdDialog.alert()
.title('Hey There...')
.content('You Must Fill All Mandatory Fields In Order To Submit The Task')
.ariaLabel('Not All Mandatory Are Filled')
.ok('Got it!')
.targetEvent(event)
);
}
/*================================= /*=================================

View file

@ -87,7 +87,7 @@
<h3><i class="fa fa-clipboard"></i> {{task.task.title}}</h3> <h3><i class="fa fa-clipboard"></i> {{task.task.title}}</h3>
<h4>Due At: {{ task.date }}</h4> <h4>Due At: {{ task.date }}</h4>
<p>{{ dueTimeFromNow }}</p> <p>{{ dueTimeFromNow }}</p>
<p>{{task.task.description}}</p> <p style="white-space: pre-wrap;">{{task.task.description}}</p>
<p>{{(task.isPersonal) ? "Personal" : "Project"}} Task</p> <p>{{(task.isPersonal) ? "Personal" : "Project"}} Task</p>
<md-divider ng-if="!$last"></md-divider> <md-divider ng-if="!$last"></md-divider>

View file

@ -1,19 +1,18 @@
<div> <div layout='row'>
<div class="spacer"></div> <div flex='20'></div>
<div layout="coulumn" flex="60">
<div layout="coulumn" flex="80">
<md-card layout-padding style="width:100%"> <md-card layout-padding style="width:100%">
<h3><i class="fa fa-clipboard"></i> {{task.title}}</h3> <h1><i class="fa fa-clipboard"></i> {{task.title}}</h1>
<h4>Due At: {{ task.date }}</h4> <h4>Due At: {{ task.date }}</h4>
<p>{{ dueTimeFromNow }}</p> <p>{{ dueTimeFromNow }}</p>
<p ng-bind-html-unsafe="task.description"></p> <p style="white-space: pre-wrap;">{{task.description}}</p>
<p>{{(task.isPersonal) ? "Personal" : "Project"}} Task</p> <p>{{(task.isPersonal) ? "Personal" : "Project"}} Task</p>
<!-- <md-divider></md-divider> --> <!-- <md-divider></md-divider> -->
<div ng-repeat="component in task.components"> <div ng-repeat="component in task.components">
<md-card layout-padding> <md-card layout-padding>
<div ng-if="conponent.isMandatory"> <div ng-if="component.isMandatory && !(component.value && component.value != '')">
<font color="red"> <font color="red">
<i class="fa fa-certificate"></i> <i class="fa fa-certificate"></i>
</font> </font>
@ -22,19 +21,19 @@
<div ng-if="component.type == 'textbox'"> <div ng-if="component.type == 'textbox'">
<md-input-container> <md-input-container>
<label>{{component.label}}</label> <label>{{component.label}}</label>
<input ng-model="component.value"> <input ng-model="component.value" ng-disabled="readOnly">
</md-input-container> </md-input-container>
</div> </div>
<!-- if Text Area --> <!-- if Text Area -->
<div ng-if="component.type == 'textarea'"> <div ng-if="component.type == 'textarea'">
<md-input-container> <md-input-container>
<label>{{component.label}}</label> <label>{{component.label}}</label>
<textarea ng-model="component.value"></textarea> <textarea ng-model="component.value" ng-disabled="readOnly"></textarea>
</md-input-container> </md-input-container>
</div> </div>
<!-- if Checkbox --> <!-- if Checkbox -->
<div ng-if="component.type == 'checkbox'"> <div ng-if="component.type == 'checkbox'">
<md-checkbox ng-model="component.value" aria-label="Checkbox 1"> <md-checkbox ng-model="component.value" aria-label="Checkbox 1" ng-disabled="readOnly">
{{ component.label}} {{ component.label}}
</md-checkbox> </md-checkbox>
</div> </div>
@ -47,15 +46,24 @@
<!-- if RadioButtons --> <!-- if RadioButtons -->
<div ng-if="component.type == 'radiobuttons'" ng-init="initRadioButtonsComp(component)"> <div ng-if="component.type == 'radiobuttons'" ng-init="initRadioButtonsComp(component)">
{{component.title}} {{component.title}}
<md-radio-group ng-model="component.value" ng-change="RB(component)"> <md-radio-group ng-model="component.value" ng-change="RB(component)" ng-disabled="readOnly">
<md-radio-button ng-repeat="option in component.values" value="{{option.text}}" class="md-primary">{{option.text}}</md-radio-button> <md-radio-button ng-repeat="option in component.values" value="{{option.text}}" class="md-primary">{{option.text}}</md-radio-button>
</md-radio-group> </md-radio-group>
</div> </div>
</md-card> </md-card>
</div> </div>
<div layout='row' ng-if='!readOnly'>
<div class='spacer'></div>
<div style='position:relative;'>
<md-button class='md-primary' ng-click='submitTask($event)'>Submit</md-button>
</div>
</div>
</md-card> </md-card>
</div> </div>
<div class="spacer"></div>
<div flex='20'></div>
</div> </div>