Improve folder subscription widget

pull/91/head
Francis Lachapelle 2014-11-12 10:44:43 -05:00
parent 989cb0bca2
commit ca14a0d4b3
6 changed files with 66 additions and 65 deletions

View File

@ -5,41 +5,44 @@
xmlns:var="http://www.skyrix.com/od/binding"
xmlns:const="http://www.skyrix.com/od/constant"
xmlns:uix="OGo:uix"><var:string var:value="doctype" const:escapeHTML="NO" />
<ul>
<li class="title"><var:string label:value="Subscribe"/></li>
<li class="search">
<input type="text" label:placeholder="Search"
data-ng-model="searchString"
data-sg-user-typeahead="sg-user-typeahead" />
</li>
<li class="item"
data-ng-repeat="user in users">
<a data-ng-click="selectUser($index)"
data-ng-mouseenter="selectActive($index)">
<span data-bind-html-unsafe="user.$shortFormat() | typeaheadHighlight:query"><!-- user --></span>
<i class="icon right"
data-ng-class="{'icon-arrow-right': user.uid != selectedUser.uid, 'icon-arrow-down': user.uid == selectedUser.uid}"><!-- arrow --></i>
</a>
<ul class="subitems"
data-ng-if="user.uid == selectedUser.uid">
<li class="item"
data-ng-show="user.$$folders.length == 0">
<a class="disabled">
<i class="icon icon-notification"><!-- no subscription --></i>
<var:string label:value="No possible subscription"/>
</a>
</li>
<li class="item"
data-ng-repeat="folder in user.$$folders">
<a>
<i class="icon"
data-ng-class="{'icon-address-book': folder.type == 'Contact'}"><!-- type --></i>
<span data-ng-bind="folder.displayName"><!-- folder --></span>
<button class="button tiny right"
data-ng-click="selectFolder(folder)">Subscribe</button>
</a>
</li>
</ul>
</li>
</ul>
<span class="joyride-nub left"><!-- dropdown nub --></span>
<div class="joyride-content-wrapper">
<ul>
<li class="title"><var:string label:value="Subscribe"/></li>
<li class="search">
<input type="text" label:placeholder="Search"
data-ng-model="searchString"
data-sg-user-typeahead="sg-user-typeahead" />
</li>
<li class="item"
data-ng-repeat="user in users">
<a data-ng-click="selectUser($index)"
data-ng-mouseenter="selectActive($index)">
<span data-bind-html-unsafe="user.$shortFormat() | typeaheadHighlight:query"><!-- user --></span>
<i class="icon right"
data-ng-class="{'icon-arrow-right': user.uid != selectedUser.uid, 'icon-arrow-down': user.uid == selectedUser.uid}"><!-- arrow --></i>
</a>
<ul class="subitems"
data-ng-if="user.uid == selectedUser.uid">
<li class="item"
data-ng-show="user.$$folders.length == 0">
<a class="disabled">
<i class="icon icon-notification"><!-- no subscription --></i>
<var:string label:value="No possible subscription"/>
</a>
</li>
<li class="item"
data-ng-repeat="folder in user.$$folders">
<a>
<i class="icon"
data-ng-class="{'icon-address-book': folder.type == 'Contact'}"><!-- type --></i>
<span data-ng-bind="folder.displayName"><!-- folder --></span>
<button class="button tiny right"
data-ng-click="selectFolder(folder)">Subscribe</button>
</a>
</li>
</ul>
</li>
</ul>
</div>
</container>

View File

@ -197,6 +197,7 @@
dropdownCss.top = $window.innerHeight - dropdownHeight - 5;
if (dropdownHeight > $window.innerHeight) {
// Resize height of dropdown to fit window
dropdownCss.top = 5;
dropdownCss.height = ($window.innerHeight - 10) + 'px';
}
}
@ -273,10 +274,7 @@
};
}],
link: function(scope, element, attrs, controller) {
// NOTE: We could also make these modifications in the wox template
element.addClass('joyride-tip-guide');
angular.element(element.children()[0]).addClass('joyride-content-wrapper');
element.prepend('<span class="joyride-nub left"></span>');
}
};
}])

View File

@ -187,7 +187,6 @@
User.$$resource.userResource(this.uid).fetch(null, 'foldersSearch', param).then(function(data) {
_this.$$folders = data;
deferred.resolve(data);
console.debug(JSON.stringify(data, undefined, 2));
return data;
});
}

View File

@ -59,9 +59,10 @@
var sibling, i;
addressbook.isOwned = this.activeUser.isSuperUser || addressbook.owner == this.activeUser.login;
addressbook.isSubscription = addressbook.owner != this.activeUser.login;
sibling = _.find(this.$addressbooks, function(o) {
return (o.isRemote || (o.id != 'personal'
&& o.isOwned == addressbook.isOwned
&& o.isSubscription === addressbook.isSubscription
&& o.name.localeCompare(addressbook.name) === 1));
});
i = sibling ? _.indexOf(_.pluck(this.$addressbooks, 'id'), sibling.id) : 1;
@ -81,7 +82,8 @@
// Instanciate AddressBook objects
angular.forEach(this.$addressbooks, function(o, i) {
_this.$addressbooks[i] = new AddressBook(o);
// Add 'isOwned' attribute based on active user (TODO: add it server-side?)
// Add 'isOwned' and 'isSubscription' attributes based on active user (TODO: add it server-side?)
_this.$addressbooks[i].isSubscription = _this.$addressbooks[i].owner != _this.activeUser.login;
_this.$addressbooks[i].isOwned = _this.activeUser.isSuperUser
|| _this.$addressbooks[i].owner == _this.activeUser.login;
});
@ -196,10 +198,10 @@
d = AddressBook.$q.defer(),
promise;
if (this.isOwned)
promise = AddressBook.$$resource.remove(this.id);
else
if (this.isSubscription)
promise = AddressBook.$$resource.fetch(this.id, 'unsubscribe');
else
promise = AddressBook.$$resource.remove(this.id);
promise.then(function() {
var i = _.indexOf(_.pluck(AddressBook.$addressbooks, 'id'), _this.id);

View File

@ -165,7 +165,18 @@
}
};
$scope.confirmDelete = function() {
if ($scope.addressbook.isOwned) {
if ($scope.addressbook.isSubscription) {
// Unsubscribe without confirmation
$rootScope.addressbook.$delete()
.then(function() {
$rootScope.addressbook = null;
}, function(data, status) {
Dialog.alert(l('An error occured while deleting the addressbook "%{0}".',
$rootScope.addressbook.name),
l(data.error));
});
}
else {
Dialog.confirm(l('Warning'), l('Are you sure you want to delete the addressbook <em>%{0}</em>?',
$scope.addressbook.name))
.then(function(res) {
@ -181,18 +192,6 @@
}
});
}
else {
// Unsubscribe without confirmation
$rootScope.addressbook.$delete()
.then(function() {
$rootScope.addressbook = null;
}, function(data, status) {
Dialog.alert(l('An error occured while deleting the addressbook "%{0}".',
$rootScope.addressbook.name),
l(data.error));
});
}
};
$scope.importCards = function() {

View File

@ -594,8 +594,6 @@ $column-gutter: 0;
.sg-dropdown-content {
background-color: #fff;
height: 300px;
overflow: hidden;
overflow-y: auto;
&.joyride-tip-guide {
.joyride-nub {
&.left {
@ -607,13 +605,15 @@ $column-gutter: 0;
}
.joyride-content-wrapper {
list-style: none;
margin: 0;
position: absolute;
top: 0;
bottom: 0;
overflow: hidden;
overflow-y: auto;
padding: 0;
ul {
margin-left: 0;
list-style-type: none;
&.subitems {
margin-left: 0;
}
}
li {
&.title {