Display description for alarm & repeat definitions

This is not the perfect solution has the localization may be unsuitable
in some languages.
This commit is contained in:
Francis Lachapelle
2015-11-12 12:29:10 -05:00
parent 98493fbcac
commit d081f3c6eb
3 changed files with 48 additions and 8 deletions
@@ -120,12 +120,12 @@
<!-- repeat -->
<md-list-item ng-show="editor.component.$isRecurrent">
<md-icon>repeat</md-icon>
<p><!-- editor.component.repeat.toString() --></p>
<p>{{editor.component.repeatDescription()}}</p>
</md-list-item>
<!-- reminder -->
<md-list-item ng-show="editor.component.$hasAlarm" ng-hide="editor.component.userHasRSVP">
<md-list-item ng-hide="!editor.component.$hasAlarm || editor.component.userHasRSVP">
<md-icon>alarm_on</md-icon>
<p><!-- editor.component.alarm.toString() --></p>
<p>{{editor.component.alarmDescription()}}</p>
</md-list-item>
<md-list-item layout-align="start start" ng-show="editor.component.organizer">
<md-icon>people</md-icon>
@@ -111,24 +111,24 @@
<p>{{editor.component.percentComplete}} %</p>
</md-list-item>
<!-- attach urls -->
<md-list-item ng-repeat="url in editor.component.attachUrls">
<md-list-item ng-repeat="url in ::editor.component.attachUrls">
<md-icon>link</md-icon>
<p><a ng-href="url.value">{{url.value}}</a></p>
</md-list-item>
<!-- comment -->
<md-list-item ng-show="editor.component.comment">
<md-icon>mode_comment</md-icon>
<p>{{editor.component.comment}}</p>
<p>{{::editor.component.comment}}</p>
</md-list-item>
<!-- repeat -->
<md-list-item ng-show="editor.component.repeat">
<md-icon>repeat</md-icon>
<p><!-- editor.component.repeat.toString() --></p>
<p>{{editor.component.repeatDescription()}}</p>
</md-list-item>
<!-- reminder -->
<md-list-item ng-show="editor.component.$hasAlarm">
<md-icon>alarm</md-icon>
<p><!-- editor.component.alarm.toString() --></p>
<md-icon>alarm_on</md-icon>
<p>{{editor.component.alarmDescription()}}</p>
</md-list-item>
</md-list>
</md-dialog-content>
@@ -1114,4 +1114,44 @@
return component;
};
/**
* @function repeatDescription
* @memberof Component.prototype
* @desc Return a localized description of the recurrence definition
* @return a localized string
*/
Component.prototype.repeatDescription = function() {
var localizedString = null;
if (this.repeat)
localizedString = l('repeat_' + this.repeat.frequency.toUpperCase());
return localizedString;
};
/**
* @function alarmDescription
* @memberof Component.prototype
* @desc Return a localized description of the reminder definition
* @return a localized string
*/
Component.prototype.alarmDescription = function() {
var key, localizedString = null;
if (this.alarm) {
key = ['reminder' + this.alarm.quantity, this.alarm.unit, this.alarm.reference].join('_');
localizedString = l(key);
if (key === localizedString)
// No localized string for this reminder definition
localizedString = [this.alarm.quantity,
l('reminder_' + this.alarm.unit),
l('reminder_' + this.alarm.reference)].join(' ');
}
return localizedString;
};
Component.prototype.toString = function() {
return '[Component ' + this.id + ']';
};
})();