Add tags input to edit mail recipients

This commit is contained in:
Francis Lachapelle
2014-12-11 21:11:20 -05:00
parent e01e0adac8
commit 09d469927f
6 changed files with 59 additions and 32 deletions
+18 -1
View File
@@ -39,8 +39,10 @@ module.exports = function(grunt) {
var options = {
'src': 'bower_components',
'js_dest': 'js/vendor/',
'fonts_dest': 'fonts/'
'fonts_dest': 'fonts/',
'css_dest': 'css/'
};
grunt.log.subhead('Copying JavaScript files');
var js = [
'<%= src %>/angular/angular{,.min}.js{,.map}',
'<%= src %>/angular-animate/angular-animate{,.min}.js{,.map}',
@@ -48,6 +50,8 @@ module.exports = function(grunt) {
'<%= src %>/angular-ui-router/release/angular-ui-router{,.min}.js',
'<%= src %>/angular-recursion/angular-recursion{,.min}.js',
'<%= src %>/angular-vs-repeat/src/angular-vs-repeat{,.min}.js',
'<%= src %>/angular-file-upload/angular-file-upload{,.min}.js{,map}',
'<%= src %>/ng-tags-input/ng-tags-input{,.min}.js',
'<%= src %>/angular-foundation/mm-foundation-tpls{,.min}.js',
'<%= src %>/foundation/js/foundation{,.min}.js',
'<%= src %>/ionic/release/js/ionic.bundle{,.min}.js',
@@ -63,6 +67,7 @@ module.exports = function(grunt) {
grunt.log.ok("copy " + src + " => " + dest);
}
}
grunt.log.subhead('Copying font files');
var fonts = grunt.file.expand(
grunt.template.process('<%= src %>/ionic/release/fonts/ionicons.*',
{data: options})
@@ -74,6 +79,18 @@ module.exports = function(grunt) {
grunt.file.copy(src, dest);
grunt.log.ok("copy " + src + " => " + dest);
}
grunt.log.subhead('Copying CSS files');
var css = grunt.file.expand(
grunt.template.process('<%= src %>/ng-tags-input/ng-tags-input*.css',
{data: options})
);
for (var i = 0; i < css.length; i++) {
var src = css[i];
var paths = src.split('/');
var dest = options.css_dest + paths[paths.length-1];
grunt.file.copy(src, dest);
grunt.log.ok("copy " + src + " => " + dest);
}
});
grunt.task.registerTask('build', ['static', 'sass']);
grunt.task.registerTask('default', ['build','watch']);
+1
View File
@@ -8,6 +8,7 @@
"angular-foundation": "~0.3",
"angular-recursion": "~1.0",
"angular-vs-repeat": ">=1.0",
"ng-tags-input": "~2.0",
"foundation": ">5.3",
"ionic": "1.0.0-beta.11",
"underscore": "~1.6"
+17 -9
View File
@@ -6,7 +6,7 @@
angular.module('SOGo.Common', []);
angular.module('SOGo.MailerUI', ['ngSanitize', 'ui.router', 'mm.foundation', 'vs-repeat', 'ck', 'SOGo.Common', 'SOGo.UICommon', 'SOGo.UIDesktop'])
angular.module('SOGo.MailerUI', ['ngSanitize', 'ui.router', 'mm.foundation', 'vs-repeat', 'ck', 'ngTagsInput', 'SOGo.Common', 'SOGo.UICommon', 'SOGo.UIDesktop'])
.constant('sgSettings', {
baseURL: ApplicationBaseURL,
@@ -18,7 +18,7 @@
}
})
.config(['$stateProvider', '$urlRouterProvider', function($stateProvider, $urlRouterProvider) {
.config(['$stateProvider', '$urlRouterProvider', 'tagsInputConfigProvider', function($stateProvider, $urlRouterProvider, tagsInputConfigProvider) {
$stateProvider
.state('mail', {
url: '/Mail',
@@ -112,6 +112,11 @@
templateUrl: 'editorTemplate', // UI/Templates/MailerUI/UIxMailEditor.wox
controller: 'MessageEditorCtrl'
}
},
resolve: {
stateContent: ['stateMessage', function(stateMessage) {
return stateMessage.$editableContent();
}]
}
})
.state('mail.newMessage', {
@@ -133,6 +138,13 @@
// if none of the above states are matched, use this as the fallback
$urlRouterProvider.otherwise('/Mail');
// Set default configuration for tags input
tagsInputConfigProvider.setDefaults('tagsInput', {
addOnComma: false,
replaceSpacesWithDashes: false,
allowedTagsPattern: /([\w\!\#$\%\&\'\*\+\-\/\=\?\^\`{\|\}\~]+\.)*[\w\!\#$\%\&\'\*\+\-\/\=\?\^\`{\|\}\~]+@((((([a-z0-9]{1}[a-z0-9\-]{0,62}[a-z0-9]{1})|[a-z])\.)+[a-z]{2,})|(\d{1,3}\.){3}\d{1,3}(\:\d{1,5})?)/i
});
}])
.run(function($rootScope) {
@@ -220,16 +232,12 @@
.controller('MessageEditorCtrl', ['$scope', '$rootScope', '$stateParams', 'stateAccounts', 'stateMessage', '$timeout', '$modal', 'sgFocus', 'sgDialog', 'sgAccount', 'sgMailbox', function($scope, $rootScope, $stateParams, stateAccounts, stateMessage, $timeout, $modal, focus, Dialog, Account, Mailbox) {
if (angular.isDefined(stateMessage)) {
$scope.message = stateMessage;
// Flatten addresses as strings
_.each(['from', 'to', 'cc', 'bcc', 'reply-to'], function(type) {
if ($scope.message[type])
$scope.message[type] = _.pluck($scope.message[type], 'full').join(', ');
});
}
$scope.identities = _.flatten(_.pluck(stateAccounts, 'identities'));
$scope.identities = _.pluck(_.flatten(_.pluck(stateAccounts, 'identities')), 'full');
$scope.send = function(message) {
message.$send().then(function(data) {
console.debug('success ' + JSON.stringify(data, undefined, 2));
$rootScope.message = null;
$state.go('mail.account.mailbox', { accountId: stateAccount.id, mailboxId: encodeUriFilter(stateMailbox.path) });
}, function(data) {
console.debug('failure ' + JSON.stringify(data, undefined, 2));
});