Skip to content

Commit

Permalink
Improve Preferences module and Mail account editor
Browse files Browse the repository at this point in the history
  • Loading branch information
cgx committed Oct 21, 2016
1 parent 6d695e8 commit 24e4c60
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 19 deletions.
30 changes: 25 additions & 5 deletions UI/Templates/PreferencesUI/UIxAccountEditor.wox
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<md-input-container class="md-block md-flex">
<label><var:string label:value="Account Name"/></label>
<input type="text" required="required"
md-autofocus="true"
ng-readonly="$AccountDialogController.accountId == 0"
ng-model="$AccountDialogController.account.name"/>
</md-input-container>
Expand All @@ -33,18 +34,37 @@

<md-input-container class="md-block" flex="30">
<label><var:string label:value="Port"/></label>
<input type="number" required="required" min="1" max="65535"
<input type="number" min="1" max="65535"
ng-disabled="$AccountDialogController.accountId == 0"
ng-model="$AccountDialogController.account.port"/>
ng-model="$AccountDialogController.account.port"
placeholder=""
sg-placeholder="$AccountDialogController.defaultPort"/>
</md-input-container>
</div>

<md-input-container class="md-block md-input-has-value">
<label><var:string label:value="Encryption"/></label>
<md-radio-group ng-model="$AccountDialogController.account.encryption">
<md-radio-button ng-disabled="$AccountDialogController.accountId == 0" value="none" class="md-primary"><var:string label:value="None"/></md-radio-button>
<md-radio-button ng-disabled="$AccountDialogController.accountId == 0" value="ssl"><var:string label:value="SSL"/></md-radio-button>
<md-radio-button ng-disabled="$AccountDialogController.accountId == 0" value="tls"><var:string label:value="TLS"/></md-radio-button>
<div layout="row" layout-align="space-around">
<div>
<md-radio-button
ng-click="$AccountDialogController.defaultPort = 143"
ng-disabled="$AccountDialogController.accountId == 0"
value="none" class="md-primary"><var:string label:value="None"/></md-radio-button>
</div>
<div>
<md-radio-button
ng-click="$AccountDialogController.defaultPort = 993"
ng-disabled="$AccountDialogController.accountId == 0"
value="ssl"><var:string label:value="SSL"/></md-radio-button>
</div>
<div>
<md-radio-button
ng-click="$AccountDialogController.defaultPort = 143"
ng-disabled="$AccountDialogController.accountId == 0"
value="tls"><var:string label:value="TLS"/></md-radio-button>
</div>
</div>
</md-radio-group>
</md-input-container>

Expand Down
3 changes: 2 additions & 1 deletion UI/Templates/PreferencesUI/UIxPreferences.wox
Original file line number Diff line number Diff line change
Expand Up @@ -739,7 +739,8 @@
<md-input-container class="md-block md-flex">
<input type="text"
label:aria-label="Label"
ng-model="value[0]"/>
ng-model="value[0]"
sg-focus-on="mailLabel_{{$index}}"/>
</md-input-container>
<md-button class="md-icon-button" type="button"
layout="row" layout-align="end center"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,19 @@
function AccountDialogController($mdDialog, defaults, account, accountId, mailCustomFromEnabled) {
var vm = this;

vm.defaultPort = 143;
vm.defaults = defaults;
vm.account = account;
vm.accountId = accountId;
vm.customFromIsReadonly = customFromIsReadonly;
vm.cancel = cancel;
vm.save = save;

if (!vm.account.encryption)
vm.account.encryption = "none";
else if (vm.account.encryption == "ssl")
vm.defaultPort = 993;

function customFromIsReadonly() {
if (accountId > 0)
return false;
Expand Down
32 changes: 19 additions & 13 deletions UI/WebServerResources/js/Preferences/PreferencesController.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,19 +115,22 @@
vm.preferences.defaults.AuxiliaryMailAccounts.push({});

account = _.last(vm.preferences.defaults.AuxiliaryMailAccounts);
account.name = l("New account");
account.identities = [
{
fullName: "",
email: ""
}
];
account.receipts = {
receiptAction: "ignore",
receiptNonRecipientAction: "ignore",
receiptOutsideDomainAction: "ignore",
receiptAnyAction: "ignore"
};
angular.extend(account,
{
name: "",
identities: [
{
fullName: "",
email: ""
}
],
receipts: {
receiptAction: "ignore",
receiptNonRecipientAction: "ignore",
receiptOutsideDomainAction: "ignore",
receiptAnyAction: "ignore"
}
});

$mdDialog.show({
controller: 'AccountDialogController',
Expand All @@ -142,6 +145,8 @@
}
}).then(function() {
form.$setDirty();
}).catch(function() {
vm.preferences.defaults.AuxiliaryMailAccounts.pop();
});
}

Expand Down Expand Up @@ -173,6 +178,7 @@
// See $omit() in the Preferences services for real key generation
var key = '_$$' + guid();
vm.preferences.defaults.SOGoMailLabelsColors[key] = ["New label", "#aaa"];
focus('mailLabel_' + (_.size(vm.preferences.defaults.SOGoMailLabelsColors) - 1));
form.$setDirty();
}

Expand Down

0 comments on commit 24e4c60

Please sign in to comment.