Skip to content

Commit 2754902

Browse files
committed
Angular js part for the author resource
- Controllers, detail and updates on the cms
1 parent 5c36cc8 commit 2754902

File tree

12 files changed

+414
-0
lines changed

12 files changed

+414
-0
lines changed

src/main/webapp/i18n/en/author.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"bookstoreApp": {
3+
"author" : {
4+
"home": {
5+
"title": "Authors",
6+
"createLabel": "Create a new Author",
7+
"createOrEditLabel": "Create or edit a Author"
8+
},
9+
"delete": {
10+
"question": "Are you sure you want to delete Author {{ id }}?"
11+
},
12+
"detail": {
13+
"title": "Author"
14+
},
15+
"name": "Name",
16+
"surname": "Surname",
17+
"description": "Description",
18+
"birthDate": "BirthDate"
19+
}
20+
}
21+
}

src/main/webapp/i18n/en/global.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"home": "Home",
77
"entities": {
88
"main": "Entities",
9+
"author": "Author",
910
"additionalEntity": "JHipster will add additional entities here (do not translate!)"
1011
},
1112
"account": {

src/main/webapp/i18n/fr/author.json

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"bookstoreApp": {
3+
"author" : {
4+
"home": {
5+
"title": "Authors",
6+
"createLabel": "Créer un nouveau Author",
7+
"createOrEditLabel": "Créer ou éditer un Author"
8+
},
9+
"delete": {
10+
"question": "Etes-vous certain de vouloir supprimer le Author {{ id }} ?"
11+
},
12+
"detail": {
13+
"title": "Author"
14+
},
15+
"name": "Name",
16+
"surname": "Surname",
17+
"description": "Description",
18+
"birthDate": "BirthDate"
19+
}
20+
}
21+
}
22+

src/main/webapp/i18n/fr/global.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"home": "Accueil",
77
"entities": {
88
"main": "Entités",
9+
"author": "Author",
910
"additionalEntity": "JHipster will add additional entities here (do not translate!)"
1011
},
1112
"account": {

src/main/webapp/index.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,10 @@
123123
<script src="scripts/components/language/language.service.js"></script>
124124
<script src="scripts/components/language/language.controller.js"></script>
125125
<script src="scripts/components/auth/provider/auth.oauth2.service.js"></script>
126+
<script src="scripts/app/entities/author/author.js"></script>
127+
<script src="scripts/app/entities/author/author.controller.js"></script>
128+
<script src="scripts/app/entities/author/author-detail.controller.js"></script>
129+
<script src="scripts/components/entities/author/author.service.js"></script>
126130
<!-- endbuild -->
127131
</body>
128132
</html>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
'use strict';
2+
3+
angular.module('bookstoreApp')
4+
.controller('AuthorDetailController', function ($scope, $stateParams, Author) {
5+
$scope.author = {};
6+
$scope.load = function (id) {
7+
Author.get({id: id}, function(result) {
8+
$scope.author = result;
9+
});
10+
};
11+
$scope.load($stateParams.id);
12+
});
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
2+
<div>
3+
<h2><span translate="bookstoreApp.author.detail.title">Author</span> {{author.id}}</h2>
4+
<div class="table-responsive">
5+
<table class="table table-striped">
6+
<thead>
7+
<tr>
8+
<th translate="entity.detail.field">Field</th>
9+
<th translate="entity.detail.value">Value</th>
10+
</tr>
11+
</thead>
12+
<tbody>
13+
<tr>
14+
<td>
15+
<span translate="bookstoreApp.author.name">Name</span>
16+
</td>
17+
<td>
18+
<input type="text" class="input-sm form-control" value="{{author.name}}" readonly>
19+
</td>
20+
</tr>
21+
<tr>
22+
<td>
23+
<span translate="bookstoreApp.author.surname">Surname</span>
24+
</td>
25+
<td>
26+
<input type="text" class="input-sm form-control" value="{{author.surname}}" readonly>
27+
</td>
28+
</tr>
29+
<tr>
30+
<td>
31+
<span translate="bookstoreApp.author.description">Description</span>
32+
</td>
33+
<td>
34+
<input type="text" class="input-sm form-control" value="{{author.description}}" readonly>
35+
</td>
36+
</tr>
37+
<tr>
38+
<td>
39+
<span translate="bookstoreApp.author.birthDate">BirthDate</span>
40+
</td>
41+
<td>
42+
<input type="text" class="input-sm form-control" value="{{author.birthDate}}" readonly>
43+
</td>
44+
</tr>
45+
</tbody>
46+
</table>
47+
</div>
48+
49+
<button type="submit"
50+
ui-sref="author"
51+
class="btn btn-info">
52+
<span class="glyphicon glyphicon-arrow-left"></span>&nbsp;<span translate="entity.action.back"> Back</span>
53+
</button>
54+
</div>
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
'use strict';
2+
3+
angular.module('bookstoreApp')
4+
.controller('AuthorController', function ($scope, Author, ParseLinks) {
5+
$scope.authors = [];
6+
$scope.page = 1;
7+
$scope.loadAll = function() {
8+
Author.query({page: $scope.page, per_page: 20}, function(result, headers) {
9+
$scope.links = ParseLinks.parse(headers('link'));
10+
$scope.authors = result;
11+
});
12+
};
13+
$scope.loadPage = function(page) {
14+
$scope.page = page;
15+
$scope.loadAll();
16+
};
17+
$scope.loadAll();
18+
19+
$scope.showUpdate = function (id) {
20+
Author.get({id: id}, function(result) {
21+
$scope.author = result;
22+
$('#saveAuthorModal').modal('show');
23+
});
24+
};
25+
26+
$scope.save = function () {
27+
if ($scope.author.id != null) {
28+
Author.update($scope.author,
29+
function () {
30+
$scope.refresh();
31+
});
32+
} else {
33+
Author.save($scope.author,
34+
function () {
35+
$scope.refresh();
36+
});
37+
}
38+
};
39+
40+
$scope.delete = function (id) {
41+
Author.get({id: id}, function(result) {
42+
$scope.author = result;
43+
$('#deleteAuthorConfirmation').modal('show');
44+
});
45+
};
46+
47+
$scope.confirmDelete = function (id) {
48+
Author.delete({id: id},
49+
function () {
50+
$scope.loadAll();
51+
$('#deleteAuthorConfirmation').modal('hide');
52+
$scope.clear();
53+
});
54+
};
55+
56+
$scope.refresh = function () {
57+
$scope.loadAll();
58+
$('#saveAuthorModal').modal('hide');
59+
$scope.clear();
60+
};
61+
62+
$scope.clear = function () {
63+
$scope.author = {name: null, surname: null, description: null, birthDate: null, id: null};
64+
$scope.editForm.$setPristine();
65+
$scope.editForm.$setUntouched();
66+
};
67+
});
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
'use strict';
2+
3+
angular.module('bookstoreApp')
4+
.config(function ($stateProvider) {
5+
$stateProvider
6+
.state('author', {
7+
parent: 'entity',
8+
url: '/author',
9+
data: {
10+
roles: ['ROLE_USER'],
11+
pageTitle: 'bookstoreApp.author.home.title'
12+
},
13+
views: {
14+
'content@': {
15+
templateUrl: 'scripts/app/entities/author/authors.html',
16+
controller: 'AuthorController'
17+
}
18+
},
19+
resolve: {
20+
translatePartialLoader: ['$translate', '$translatePartialLoader', function ($translate, $translatePartialLoader) {
21+
$translatePartialLoader.addPart('author');
22+
return $translate.refresh();
23+
}]
24+
}
25+
})
26+
.state('authorDetail', {
27+
parent: 'entity',
28+
url: '/author/:id',
29+
data: {
30+
roles: ['ROLE_USER'],
31+
pageTitle: 'bookstoreApp.author.detail.title'
32+
},
33+
views: {
34+
'content@': {
35+
templateUrl: 'scripts/app/entities/author/author-detail.html',
36+
controller: 'AuthorDetailController'
37+
}
38+
},
39+
resolve: {
40+
translatePartialLoader: ['$translate', '$translatePartialLoader', function ($translate, $translatePartialLoader) {
41+
$translatePartialLoader.addPart('author');
42+
return $translate.refresh();
43+
}]
44+
}
45+
});
46+
});

0 commit comments

Comments
 (0)