Add creation & deletion of addressbooks

This commit is contained in:
Francis Lachapelle
2014-09-10 16:20:52 -04:00
parent 2672f1a8fc
commit 87cc6bed7c
10 changed files with 308 additions and 62 deletions
+19 -1
View File
@@ -64,7 +64,25 @@
return deferred.promise;
};
Resource.prototype.set = function(uid, newValue, options) {
/**
* @function create
* @desc Create a new resource using a specific action
* @param {string} action - the action to be used in the URL
* @param {string} name - the new resource's name
*/
Resource.prototype.create = function(action, name) {
var deferred = this._q.defer();
var path = this._path + '/' + action;
this._http
.post(path, { 'name': name })
.success(deferred.resolve)
.error(deferred.reject);
return deferred.promise;
};
Resource.prototype.save = function(uid, newValue, options) {
var deferred = this._q.defer();
var action = (options && options.action)? options.action : 'save';
var path = this._path + '/' + uid + '/' + action;
+37 -5
View File
@@ -5,8 +5,8 @@
'use strict';
/**
* @name Dialog (sgDialog factory in SOGo.UIDesktop)
* @desc Dialog object constructor
* @name Dialog
* @constructor
*/
function Dialog() {
}
@@ -19,7 +19,7 @@
*/
Dialog.alert = function(title, content) {
var modal = this.$modal.open({
template:
template:
'<h2 data-ng-bind-html="title"></h2>' +
'<p data-ng-bind-html="content"></p>' +
'<a class="button button-primary" ng-click="closeModal()">' + l('OK') + '</a>' +
@@ -46,7 +46,7 @@
Dialog.confirm = function(title, content) {
var d = this.$q.defer();
var modal = this.$modal.open({
template:
template:
'<h2 data-ng-bind-html="title"></h2>' +
'<p data-ng-bind-html="content"></p>' +
'<a class="button button-primary" ng-click="confirm()">' + l('OK') + '</a>' +
@@ -69,7 +69,39 @@
return d.promise;
};
/* The factory we'll use to register with Angular */
Dialog.prompt = function(title, inputPlaceholder, options) {
var o = options || {};
var d = this.$q.defer();
var modal = this.$modal.open({
template:
'<h2 ng-bind-html="title"></h2>' +
'<form><input type="' + (o.inputType || 'text')
+ '" placeholder="' + (inputPlaceholder || '') + '" ng-model="inputValue" /></form>' +
'<a class="button button-primary" ng-click="confirm(inputValue)">' + l('OK') + '</a>' +
'<a class="button button-secondary" ng-click="closeModal()">' + l('Cancel') + '</a>' +
'<span class="close-reveal-modal" ng-click="closeModal()"><i class="icon-close"></i></span>',
windowClass: 'small',
controller: function($scope, $modalInstance) {
$scope.title = title;
$scope.inputValue = o.inputValue || '';
$scope.closeModal = function() {
$modalInstance.close();
d.resolve(false);
};
$scope.confirm = function(value) {
$modalInstance.close();
d.resolve(value);
};
}
});
return d.promise;
};
/**
* @memberof Dialog
* @desc The factory we'll register as sgDialog in the Angular module SOGo.UIDesktop
*/
Dialog.$factory = ['$modal', '$q', function($modal, $q) {
angular.extend(Dialog, { $modal: $modal, $q: $q });
+18 -4
View File
@@ -4,7 +4,10 @@
(function() {
'use strict';
/* Dialog */
/**
* @name Dialog
* @constructor
*/
function Dialog() {
}
@@ -17,14 +20,25 @@
};
Dialog.confirm = function(title, content) {
var alertPopup = this.$ionicPopup.confirm({
var confirmPopup = this.$ionicPopup.confirm({
title: title,
template: content
});
return alertPopup;
return confirmPopup;
};
/* The factory we'll use to register with Angular */
Dialog.prompt = function(title, content) {
var promptPopup = this.$ionicPopup.prompt({
title: title,
inputPlaceholder: content
});
return promptPopup;
};
/**
* @memberof Dialog
* @desc The factory we'll register as sgDialog in the Angular module SOGo.UIMobile
*/
Dialog.$factory = ['$ionicPopup', function($ionicPopup) {
angular.extend(Dialog, { $ionicPopup: $ionicPopup });