Skip to content

Commit ae4852c

Browse files
resource wrapping
1 parent 878cca4 commit ae4852c

File tree

5 files changed

+18
-7
lines changed

5 files changed

+18
-7
lines changed

add_angular.dfpkg

110 Bytes
Binary file not shown.

add_angular.zip

110 Bytes
Binary file not shown.

add_angular/app/app.js

+11-4
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ angular.module('addressbook', [
1212

1313
])
1414

15-
.constant('INSTANCE_URL', '')
15+
.constant('INSTANCE_URL', 'http://dreamfactory:8888')
1616

17-
.constant('APP_API_KEY', 'b6b16dab500f8c9649e365410200a09ad30dc2b3a202f56611d9f6e98f7729c0')
17+
.constant('APP_API_KEY', '678104aec64b4e8f575ed6789f0214ef99330e6db6334b41d10551efa1864620')
1818

1919
.run([
2020
'$cookies', 'APP_API_KEY', '$http', '$rootScope', '$window',
@@ -71,15 +71,22 @@ angular.module('addressbook', [
7171
// Append instance url before every api call
7272
if (config.url.indexOf('/api/v2') > -1) {
7373
config.url = INSTANCE_URL + config.url;
74+
75+
if (config.method == 'POST' || config.method == 'PUT' || config.method == 'PATCH') {
76+
var data;
77+
if (Array.isArray(config.data)) {
78+
config.data = { resource: config.data };
79+
} else {
80+
config.data = { resource: [config.data] };
81+
}
82+
}
7483
};
7584

7685
// delete x-dreamfactory-session-token header if login
7786
if (config.method.toLowerCase() === 'post' && config.url.indexOf('/api/v2/user/session') > -1) {
7887
delete config.headers['X-DreamFactory-Session-Token'];
7988
}
8089

81-
console.log(config);
82-
8390
return config;
8491
},
8592

add_angular/app/contact-info/contact-info.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,14 @@ angular.module('contact-info', [
6969

7070

7171
$scope.addEditContactInfo = function (ev, item) {
72+
console.log('Contact info')
7273
$mdDialog.show({
7374
controller: 'ContactInfoUpdateCtrl',
7475
templateUrl: 'app/contact-info/contact-info-add-edit.html',
7576
parent: angular.element(document.body),
7677
targetEvent: ev,
7778
locals: {
78-
contactInfo: item || { contact_id: $route.current.params.id, id: '' }
79+
contactInfo: item || { contact_id: $route.current.params.id }
7980
}
8081
}).then(function () {
8182
$scope.loadData();
@@ -93,6 +94,9 @@ angular.module('contact-info', [
9394
function ($mdScope, $mdDialog, ContactInfo, contactInfo, $mdToast) {
9495
$mdScope.contactInfo = angular.copy(contactInfo);
9596
$mdScope.info_types = [ 'home', 'work', 'mobile' ];
97+
if ($mdScope.contactInfo.id === '') {
98+
delete $mdScope.contactInfo;
99+
}
96100

97101
$mdScope.submit = function () {
98102
if (!$mdScope.contactInfo.id) {

add_angular/app/contacts/contacts.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ angular.module('contacts', [
2929
controller : 'ContactsItemCtrl',
3030
resolve : {
3131
contact: function () {
32-
return { id: null };
32+
return { };
3333
},
3434
groups: function (Groups) {
3535
return Groups.query().$promise;
@@ -201,7 +201,7 @@ angular.module('contacts', [
201201
parent: angular.element(document.body),
202202
targetEvent: ev,
203203
locals: {
204-
contactInfo: item || { contact_id: $route.current.params.id, id: '' }
204+
contactInfo: item || { contact_id: $route.current.params.id }
205205
}
206206
}).then(function () {
207207
$scope.loadData();

0 commit comments

Comments
 (0)