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

Commit 88254ce

Browse files
committed
Renames Items to Pages
1 parent 16b1015 commit 88254ce

10 files changed

Lines changed: 151 additions & 141 deletions

File tree

client/app/index.html

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@
4343
<script src="bower_components/angular-touch/angular-touch.js"></script>
4444
<script src="bower_components/angular-ui-router/release/angular-ui-router.js"></script>
4545
<script src="bower_components/angular-formly/dist/formly.bootstrap.min.js"></script>
46-
<script src="bower_components/angular-formly/dist/formly.bootstrap.min.map"></script>
4746
<script src="bower_components/angular-toasty/js/ng-toasty.js"></script>
4847
<script src="bower_components/angular-file-upload/angular-file-upload.js"></script>
4948
<!-- endbower -->
@@ -60,7 +59,7 @@
6059
<script src="scripts/directives/register.js"></script>
6160
<script src="scripts/services/appauth.js"></script>
6261
<script src="scripts/directives/home.js"></script>
63-
<script src="scripts/controllers/items.js"></script>
62+
<script src="scripts/controllers/pages.js"></script>
6463
<script src="scripts/controllers/users.js"></script>
6564
<script src="scripts/controllers/sandbox.js"></script>
6665
<script src="scripts/controllers/notes.js"></script>

client/app/scripts/controllers/items.js

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

client/app/scripts/controllers/main.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ angular.module('loopbackApp')
3535
sref: 'app.events.list',
3636
icon: 'fa-calendar-o'
3737
} , {
38-
name: 'Items',
39-
sref: 'app.items.list',
38+
name: 'Pages',
39+
sref: 'app.pages.list',
4040
icon: 'fa-file-o'
4141
} , {
4242
name: 'Notes',
Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
'use strict';
2+
3+
/**
4+
* @ngdoc function
5+
* @name loopbackApp.controller:PagesCtrl
6+
* @description
7+
* # PagesCtrl
8+
* Controller of the loopbackApp
9+
*/
10+
angular.module('loopbackApp')
11+
.config(function($stateProvider) {
12+
$stateProvider.state('app.pages', {
13+
abstract: true,
14+
url: '/pages',
15+
templateUrl: 'views/pages/main.html',
16+
controller: 'PagesCtrl'
17+
})
18+
.state('app.pages.list', {
19+
url: '',
20+
templateUrl: 'views/pages/list.html',
21+
controller: 'PagesCtrl'
22+
})
23+
.state('app.pages.add', {
24+
url: '/add',
25+
templateUrl: 'views/pages/form.html',
26+
controller: 'PagesCtrl'
27+
})
28+
.state('app.pages.edit', {
29+
url: '/:id/edit',
30+
templateUrl: 'views/pages/form.html',
31+
controller: 'PagesCtrl'
32+
})
33+
.state('app.pages.view', {
34+
url: '/:id',
35+
templateUrl: 'views/pages/view.html',
36+
controller: 'PagesCtrl'
37+
});
38+
})
39+
40+
.controller('PagesCtrl', function($scope, $state, $stateParams, toasty, Page) {
41+
42+
var pageId = $stateParams.id;
43+
44+
if (pageId) {
45+
$scope.page = Page.findById({
46+
id: pageId
47+
}, function() {}, function(err) {
48+
console.log(err);
49+
});
50+
} else {
51+
$scope.page = {};
52+
}
53+
54+
function loadPages() {
55+
$scope.pages = Page.find();
56+
}
57+
58+
loadPages();
59+
60+
$scope.delete = function(id) {
61+
// if (confirm('Are you sure?') === false) {
62+
// return false;
63+
// }
64+
Page.deleteById(id, function() {
65+
toasty.pop.success({title: 'Page deleted', msg: 'Your page is deleted!', sound: false});
66+
loadPages();
67+
$state.go('app.pages.list');
68+
console.log();
69+
}, function(err) {
70+
toasty.pop.error({title: 'Error deleting page', msg: 'Your page is not deleted: ' + err, sound: false});
71+
});
72+
73+
};
74+
75+
$scope.formFields = [{
76+
key: 'name',
77+
label: 'Name',
78+
type: 'text',
79+
required: true
80+
}, {
81+
key: 'slug',
82+
label: 'Slug',
83+
type: 'text'
84+
}, {
85+
key: 'content',
86+
label: 'Content',
87+
type: 'textarea'
88+
}, {
89+
key: 'extended',
90+
label: 'Extended content',
91+
type: 'textarea'
92+
}];
93+
94+
$scope.formOptions = {
95+
96+
//Set the id of the form
97+
uniqueFormId: true,
98+
99+
//Hide the submit button that is added automaticaly
100+
//default: false
101+
hideSubmit: false,
102+
103+
//Set the text on the default submit button
104+
//default: Submit
105+
submitCopy: 'Save'
106+
};
107+
108+
$scope.onSubmit = function() {
109+
110+
Page.upsert($scope.page, function() {
111+
toasty.pop.success({title: 'Page saved', msg: 'Your page is safe with us!', sound: false});
112+
$state.go('^.list');
113+
}, function(err) {
114+
console.log(err);
115+
});
116+
117+
};
118+
119+
120+
});
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
<h4>
22
<a href="" ui-sref="^.list" class="btn btn-default"><i class="fa fa-arrow-left"></i></a>
33

4-
<span ng-show="!item.id">Add a new item</span>
5-
<span ng-show="item.id">Edit item</span>
4+
<span ng-show="!page.id">Add a new page</span>
5+
<span ng-show="page.id">Edit page</span>
66

77
</h4>
88

99

1010
<div class="row">
1111
<div class="col-md-4">
12-
<div class="alert alert-danger" ng-if="addError">Could not add item!</div>
13-
<formly-form result="item" fields="formFields" options="formOptions" ng-submit="onSubmit()"></formly-form>
12+
<div class="alert alert-danger" ng-if="addError">Could not add page!</div>
13+
<formly-form result="page" fields="formFields" options="formOptions" ng-submit="onSubmit()"></formly-form>
1414
</div>
1515
</div>
Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,24 @@
1-
2-
31
<div class='list-group'>
4-
<div ng-repeat="item in items" class="list-group-item">
2+
<div ng-repeat="page in pages" class="list-group-item">
53

64
<span class="pull-right btn-group" style="margin-top: 7px;">
7-
<a href="" class="btn btn-sm btn-default" ui-sref="^.edit({id: item.id})">
5+
<a href="" class="btn btn-sm btn-default" ui-sref="^.edit({id: page.id})">
86
<i class="fa fa-pencil"></i>
97
</a>
10-
<a href="" class="btn btn-sm btn-default" ng-click="delete({id: item.id})">
8+
<a href="" class="btn btn-sm btn-default" ng-click="delete({id: page.id})">
119
<i class="fa fa-trash-o"></i>
1210
</a>
1311
</span>
1412

1513
<h4 class="list-group-item-heading">
16-
<a href="" ui-sref="^.view({id: item.id})">{{item.name}}</a>
14+
<a href="" ui-sref="^.view({id: page.id})">{{page.name}}</a>
1715
</h4>
18-
<p class="list-group-item-text">{{item.description}}</p>
19-
16+
<p class="list-group-item-text">{{page.slug}}</p>
2017
</div>
2118

22-
<div ng-show="!items.length" class="list-group-item">
19+
<div ng-show="!pages.length" class="list-group-item">
2320
<h4 class="list-group-item-heading">
24-
There are no items
21+
There are no pages
2522
</h4>
2623
<p class="list-group-item-text">Click <a href="" ui-sref="^.add">here</a> to add one!</p>
2724
</div>
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
<h2 class="page-header">
3-
Items
4-
<small>Manage your items here!</small>
3+
Pages
4+
<small>Manage your pages here!</small>
55
<a ui-sref=".add" class="btn btn-default pull-right">Add</a>
66
</h2>
77

Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11

22
<h4>
33
<a href="" ui-sref="^.list" class="btn btn-default"><i class="fa fa-arrow-left"></i></a>
4-
{{item.name}}
4+
{{page.name}}
55

66
<span class="pull-right btn-group" style="margin-top: 7px;">
7-
<a href="" class="btn btn-sm btn-default" ui-sref="^.edit({id: item.id})">
7+
<a href="" class="btn btn-sm btn-default" ui-sref="^.edit({id: page.id})">
88
<i class="fa fa-pencil"></i>
99
</a>
10-
<a href="" class="btn btn-sm btn-default" ng-click="delete({id: item.id})">
10+
<a href="" class="btn btn-sm btn-default" ng-click="delete({id: page.id})">
1111
<i class="fa fa-trash-o"></i>
1212
</a>
1313
</span>
1414

1515
</h4>
1616
<hr>
17-
<pre>{{item | json}}</pre>
17+
<pre>{{page | json}}</pre>
Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,22 @@
11
{
2-
"name": "item",
3-
"plural": "items",
2+
"name": "Page",
3+
"plural": "pages",
44
"base": "PersistedModel",
55
"properties": {
66
"id": {
77
"type": "string"
88
},
99
"name": {
10+
"type": "string",
11+
"required": true
12+
},
13+
"slug": {
14+
"type": "string"
15+
},
16+
"content": {
1017
"type": "string"
1118
},
12-
"description": {
19+
"extended": {
1320
"type": "string"
1421
}
1522
},

server/model-config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"dataSource": "db",
2626
"public": false
2727
},
28-
"item": {
28+
"Page": {
2929
"dataSource": "db",
3030
"public": true
3131
},

0 commit comments

Comments
 (0)