a3538b64993be46a917e22bc14b78dd738c8ce09
[civicrm-core.git] / ext / msgtplui / ang / msgtplui / EditContent.js
1 (function (angular, $, _) {
2 angular.module('msgtplui').component('msgtpluiEditContent', {
3 bindings: {
4 onPreview: '&',
5 options: '='
6 },
7 templateUrl: '~/msgtplui/EditContent.html',
8 controller: function ($scope, $element, crmStatus, crmUiAlert, dialogService, $rootScope) {
9 var ts = $scope.ts = CRM.ts('msgtplui');
10 var $ctrl = this;
11
12 $ctrl.isDisabled = function() {
13 return $ctrl.options.disabled;
14 };
15
16 $ctrl.monacoOptions = function (opts) {
17 return angular.extend({}, {
18 readOnly: $ctrl.isDisabled(),
19 wordWrap: 'wordWrapColumn',
20 wordWrapColumn: 100,
21 wordWrapMinified: false,
22 wrappingIndent: 'indent'
23 }, opts);
24 };
25
26 $ctrl.openFull = function(title, fld, monacoOptions) {
27 var model = {
28 title: title,
29 monacoOptions: $ctrl.monacoOptions(angular.extend({crmHeightPct: 0.80}, monacoOptions)),
30 openPreview: function(options) {
31 return $ctrl.openPreview(options);
32 },
33 record: $ctrl.options.record,
34 field: fld,
35 tokenList: $ctrl.options.tokenList
36 };
37 var options = CRM.utils.adjustDialogDefaults({
38 // show: {effect: 'slideDown'},
39 dialogClass: 'msgtplui-dialog',
40 autoOpen: false,
41 height: '90%',
42 width: '90%'
43 });
44 return dialogService.open('expandedEditDlg', '~/msgtplui/ExpandedEdit.html', model, options)
45 // Nothing to do but hide warnings. The field was edited live.
46 .then(function(){}, function(){});
47 };
48
49 $ctrl.openPreview = function(options) {
50 $rootScope.$emit('previewMsgTpl', options);
51 };
52
53 }
54 });
55 })(angular, CRM.$, CRM._);