mirror of
https://github.com/inverse-inc/sogo.git
synced 2026-07-05 08:34:30 +00:00
Use sgSearch directive in Webmail module
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
xmlns="http://www.w3.org/1999/xhtml"
|
||||
xmlns:var="http://www.skyrix.com/od/binding"
|
||||
xmlns:const="http://www.skyrix.com/od/constant"
|
||||
xmlns:label="OGo:label"
|
||||
className="UIxPageFrame"
|
||||
title="title"
|
||||
const:userDefaultsKeys="SOGoMailMessageCheck,SOGoRefreshViewCheck,SOGoMailSortByThreads,SOGoMailListViewColumnsOrder,SOGoMailDisplayRemoteInlineImages,SOGoMailComposeMessageType,SOGoMailReplyPlacement"
|
||||
@@ -323,17 +324,20 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="md-toolbar-tools md-toolbar-tools-bottom" layout="row" layout-align="space-between center">
|
||||
<div class="cols-6" layout="row" layout-align="space-between center" style="padding-right: 16px">
|
||||
<div class="cols-6" layout="row" layout-align="space-between center" style="padding-right: 16px"
|
||||
sg-search="mailbox.$filter({ sort: 'date', asc: false }, [{ searchBy: searchField, searchInput: searchText }])">
|
||||
<md-input-container class="sg-search-field-container">
|
||||
<label style="color: white"><i class="md-icon-search"><!--icon--></i>Search</label>
|
||||
<input name="folderSearch" type="search"
|
||||
ng-model="search.filter" ng-keyup="doSearch($event)" style="color: white"/>
|
||||
<label style="color: white"><i class="md-icon-search"><!--icon--></i><var:string label:value="Search"/></label>
|
||||
<input name="folderSearch" type="search" style="color: white"/>
|
||||
</md-input-container>
|
||||
|
||||
<div class="sg-toolbar-group">
|
||||
<md-select class="sg-toolbar-sort md-contrast-light" label:placeholder="All"
|
||||
ng-model="search.criteria">
|
||||
<md-option value="all">ALL</md-option>
|
||||
<md-select class="sg-toolbar-sort md-contrast-light">
|
||||
<md-option value="subject"><var:string label:value="Subject"/></md-option>
|
||||
<md-option value="sender"><var:string label:value="Sender"/></md-option>
|
||||
<md-option value="subject_or_sender"><var:string label:value="Subject or Sender"/></md-option>
|
||||
<md-option value="to_or_cc"><var:string label:value="To or Cc"/></md-option>
|
||||
<md-option value="body"><var:string label:value="Entire Message"/></md-option>
|
||||
</md-select>
|
||||
<md-button class="iconButton" aria-label="create" ui-sref="mail.newMessage()">
|
||||
<i class="md-icon-create"><!-- icon --></i>
|
||||
|
||||
@@ -73,7 +73,7 @@
|
||||
Mailbox.$find = function(account) {
|
||||
var path, futureMailboxData;
|
||||
|
||||
futureMailboxData = this.$$resource.post(account.id, 'view', {sortingAttributes: {sort: 'date', asc: false}});
|
||||
futureMailboxData = this.$$resource.fetch(account.id.toString(), 'view');
|
||||
|
||||
return Mailbox.$unwrapCollection(account, futureMailboxData); // a collection of mailboxes
|
||||
};
|
||||
@@ -113,7 +113,7 @@
|
||||
* @memberof Mailbox
|
||||
* @desc Build the path of the mailbox (or account only).
|
||||
* @param {string} accountId - the account ID
|
||||
* @param {string} [mailboxPath] - an array of the mailbox path components
|
||||
* @param {string} [mailboxPath] - the mailbox path
|
||||
* @returns a string representing the path relative to the mail module
|
||||
*/
|
||||
Mailbox.$absolutePath = function(accountId, mailboxPath) {
|
||||
@@ -141,15 +141,44 @@
|
||||
};
|
||||
|
||||
/**
|
||||
* @function $reload
|
||||
* @function $filter
|
||||
* @memberof Mailbox.prototype
|
||||
* @desc Fetch the messages metadata of the mailbox.
|
||||
* @desc Fetch the messages metadata of the mailbox
|
||||
* @param {object} [sort] - sort preferences. Defaults to descendent by date.
|
||||
* @param {string} sort.match - either AND or OR
|
||||
* @param {string} sort.sort - either arrival, subject, from, to, date, or size
|
||||
* @param {boolean} sort.asc - sort is ascendant if true
|
||||
* @param {object[]} [filers] - list of filters for the query
|
||||
* @param {string} filers.searchBy - either subject, from, to, cc, or body
|
||||
* @param {string} filers.searchInput - the search string to match
|
||||
* @param {boolean} filers.negative - negate the condition
|
||||
* @returns a promise of the HTTP operation
|
||||
*/
|
||||
Mailbox.prototype.$reload = function() {
|
||||
var futureMailboxData;
|
||||
Mailbox.prototype.$filter = function(sort, filters) {
|
||||
var futureMailboxData, options;
|
||||
|
||||
futureMailboxData = Mailbox.$$resource.post(this.id, 'view', {sortingAttributes: {sort: 'date', asc: false}});
|
||||
if (!angular.isDefined(sort)) {
|
||||
sort = { sortingAttributes: { match: 'OR', sort: 'date', asc: false } };
|
||||
}
|
||||
options = { sortingAttributes: sort };
|
||||
if (angular.isDefined(filters)) {
|
||||
options.filters = _.reject(filters, function(filter) {
|
||||
return angular.isUndefined(filter.searchInput) || filter.searchInput.length == 0;
|
||||
});
|
||||
_.each(options.filters, function(filter) {
|
||||
var secondFilter,
|
||||
match = filter.searchBy.match(/(\w+)_or_(\w+)/);
|
||||
if (match) {
|
||||
options.sortingAttributes.match = 'OR';
|
||||
filter.searchBy = match[1];
|
||||
secondFilter = angular.copy(filter);
|
||||
secondFilter.searchBy = match[2];
|
||||
options.filters.push(secondFilter);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
futureMailboxData = Mailbox.$$resource.post(this.id, 'view', options);
|
||||
|
||||
return this.$unwrap(futureMailboxData);
|
||||
};
|
||||
|
||||
@@ -89,7 +89,7 @@
|
||||
return _find(stateAccount.$mailboxes);
|
||||
}],
|
||||
stateMessages: ['stateMailbox', function(stateMailbox) {
|
||||
return stateMailbox.$reload();
|
||||
return stateMailbox.$filter();
|
||||
}]
|
||||
}
|
||||
})
|
||||
@@ -235,7 +235,7 @@
|
||||
|
||||
.controller('MailboxCtrl', ['$scope', '$rootScope', '$stateParams', 'stateAccount', 'stateMailbox', '$timeout', 'sgFocus', 'sgDialog', 'sgAccount', 'sgMailbox', function($scope, $rootScope, $stateParams, stateAccount, stateMailbox, $timeout, focus, Dialog, Account, Mailbox) {
|
||||
$scope.account = stateAccount;
|
||||
$scope.mailbox = stateMailbox;
|
||||
$rootScope.mailbox = stateMailbox;
|
||||
$rootScope.currentFolder = stateMailbox;
|
||||
$timeout(function() {
|
||||
$rootScope.$broadcast('sgSelectFolder', stateMailbox.id);
|
||||
|
||||
Reference in New Issue
Block a user