Skip to content
This repository was archived by the owner on Oct 5, 2020. It is now read-only.

Commit cd344fe

Browse files
Nishad BakshiNishad Bakshi
authored andcommitted
replaced remaining directives with components
1 parent d5d4ee8 commit cd344fe

17 files changed

+126
-155
lines changed
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<div class='similar-items'>
22
<!--h3>Similar Documents</h3-->
33
<ul>
4-
<li ng-repeat="uri in similar">
4+
<li ng-repeat="uri in $ctrl.similar">
55
<a ui-sref="root.view({uri: uri})">{{ uri }}</a>
66
</li>
77
</ul>
8-
</div>
8+
</div>
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
(function() {
2+
3+
'use strict';
4+
5+
angular.module('app.similar')
6+
.component('mlSimilar', {
7+
bindings: {
8+
uri: '@',
9+
limit: '@'
10+
},
11+
controller: MlSimilar,
12+
templateUrl: 'app/detail/similar-component.html'
13+
});
14+
15+
MlSimilar.$inject = ['MLRest'];
16+
17+
function MlSimilar(mlRest) {
18+
var ctrl = this;
19+
20+
mlRest.extension('extsimilar', {
21+
method: 'GET',
22+
params: {
23+
'rs:uri': ctrl.uri,
24+
'rs:limit': ctrl.limit ? ctrl.limit : 10
25+
}
26+
}).then(function(response) {
27+
ctrl.similar = response.data.similar;
28+
});
29+
}
30+
31+
32+
}());

app/templates/ui/app/detail/similar-directive.js

Lines changed: 0 additions & 32 deletions
This file was deleted.
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
<div>
2-
<form ng-class="{'navbar-form navbar-right': mode === 'inline' }" ng-submit="ctrl.login()">
3-
<div class="alert alert-danger" ng-show="ctrl.loginService.loginError()" ng-cloak>Username and/or Password Incorrect</div>
2+
<form ng-class="{'navbar-form navbar-right': mode === 'inline' }" ng-submit="$ctrl.login()">
3+
<div class="alert alert-danger" ng-show="$ctrl.loginService.loginError()" ng-cloak>Username and/or Password Incorrect</div>
44
<div class="form-group">
5-
<input type="text" placeholder="Username" class="form-control" ng-model="ctrl.username">
5+
<input type="text" placeholder="Username" class="form-control" ng-model="$ctrl.username">
66
</div>
77
<div class="form-group">
8-
<input type="password" placeholder="Password" class="form-control" ng-model="ctrl.password">
8+
<input type="password" placeholder="Password" class="form-control" ng-model="$ctrl.password">
99
</div>
10-
<button ng-if="showCancel" type="button" class="btn btn-default" ng-click="ctrl.cancel()">Cancel</button>
10+
<button ng-if="showCancel" type="button" class="btn btn-default" ng-click="$ctrl.cancel()">Cancel</button>
1111
<button type="submit" class="btn btn-success">Sign in</button>
1212
</form>
1313
</div>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
(function() {
2+
3+
'use strict';
4+
5+
angular.module('app.login')
6+
.component('login', {
7+
bindings: {
8+
showCancel: '=',
9+
mode: '@',
10+
callback: '&'
11+
},
12+
controller: 'LoginCtrl',
13+
templateUrl: 'app/login/login-component.html',
14+
});
15+
16+
}());

app/templates/ui/app/login/login.controller.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@
3535
}
3636

3737
function callback(user) {
38-
if ($scope.callback && !loginService.loginError()) {
39-
$scope.callback({
38+
if (ctrl.callback && !loginService.loginError()) {
39+
ctrl.callback({
4040
user: user
4141
});
4242
}

app/templates/ui/app/login/login.directive.js

Lines changed: 0 additions & 23 deletions
This file was deleted.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<div ng-show="$ctrl.msg">
2+
<h3>{{$ctrl.msg.title || $ctrl.msg}}</h3>
3+
<p>{{$ctrl.msg.body}}</p>
4+
</div>

app/templates/ui/app/message-board/message-board-dir.html

Lines changed: 0 additions & 4 deletions
This file was deleted.

app/templates/ui/app/message-board/message-board.directive.js renamed to app/templates/ui/app/message-board/message-board.component.js

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,15 @@
1-
(function () {
1+
(function() {
22

33
'use strict';
44

55
angular.module('app.messageBoard')
6-
.directive('messageBoard', MessageBoardDirective)
7-
.controller('MessageBoardController', MessageBoardController);
8-
9-
function MessageBoardDirective() {
10-
return {
11-
restrict: 'E',
12-
controller: 'MessageBoardController',
13-
controllerAs: 'ctrl',
14-
replace: true,
15-
scope: {
6+
.component('messageBoard', {
7+
bindings: {
168
msg: '='
179
},
18-
templateUrl: 'app/message-board/message-board-dir.html'
19-
};
20-
}
10+
controller: MessageBoardController,
11+
templateUrl: 'app/message-board/message-board-component.html',
12+
});
2113

2214
MessageBoardController.$inject = ['$scope'];
2315

0 commit comments

Comments
 (0)