Ohm-Management - Projektarbeit B-ME
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

VEditDialog.js 4.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. 'use strict';
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. require('../../../src/stylus/components/_small-dialog.styl');
  6. var _returnable = require('../../mixins/returnable');
  7. var _returnable2 = _interopRequireDefault(_returnable);
  8. var _themeable = require('../../mixins/themeable');
  9. var _themeable2 = _interopRequireDefault(_themeable);
  10. var _helpers = require('../../util/helpers');
  11. var _VBtn = require('../VBtn');
  12. var _VBtn2 = _interopRequireDefault(_VBtn);
  13. var _VMenu = require('../VMenu');
  14. var _VMenu2 = _interopRequireDefault(_VMenu);
  15. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  16. /* @vue/component */
  17. exports.default = {
  18. name: 'v-edit-dialog',
  19. mixins: [_returnable2.default, _themeable2.default],
  20. props: {
  21. cancelText: {
  22. default: 'Cancel'
  23. },
  24. large: Boolean,
  25. lazy: Boolean,
  26. persistent: Boolean,
  27. saveText: {
  28. default: 'Save'
  29. },
  30. transition: {
  31. type: String,
  32. default: 'slide-x-reverse-transition'
  33. }
  34. },
  35. data: function data() {
  36. return {
  37. isActive: false
  38. };
  39. },
  40. watch: {
  41. isActive: function isActive(val) {
  42. if (val) {
  43. this.$emit('open');
  44. setTimeout(this.focus, 50); // Give DOM time to paint
  45. } else {
  46. this.$emit('close');
  47. }
  48. }
  49. },
  50. methods: {
  51. cancel: function cancel() {
  52. this.isActive = false;
  53. this.$emit('cancel');
  54. },
  55. focus: function focus() {
  56. var input = this.$refs.content.querySelector('input');
  57. input && input.focus();
  58. },
  59. genButton: function genButton(fn, text) {
  60. return this.$createElement(_VBtn2.default, {
  61. props: {
  62. flat: true,
  63. color: 'primary',
  64. light: true
  65. },
  66. on: { click: fn }
  67. }, text);
  68. },
  69. genActions: function genActions() {
  70. var _this = this;
  71. return this.$createElement('div', {
  72. 'class': 'v-small-dialog__actions'
  73. }, [this.genButton(this.cancel, this.cancelText), this.genButton(function () {
  74. _this.save(_this.returnValue);
  75. _this.$emit('save');
  76. }, this.saveText)]);
  77. },
  78. genContent: function genContent() {
  79. var _this2 = this;
  80. return this.$createElement('div', {
  81. on: {
  82. keydown: function keydown(e) {
  83. var input = _this2.$refs.content.querySelector('input');
  84. e.keyCode === _helpers.keyCodes.esc && _this2.cancel();
  85. if (e.keyCode === _helpers.keyCodes.enter && input) {
  86. _this2.save(input.value);
  87. _this2.$emit('save');
  88. }
  89. }
  90. },
  91. ref: 'content'
  92. }, [this.$slots.input]);
  93. }
  94. },
  95. render: function render(h) {
  96. var _this3 = this;
  97. return h(_VMenu2.default, {
  98. staticClass: 'v-small-dialog',
  99. class: this.themeClasses,
  100. props: {
  101. contentClass: 'v-small-dialog__content',
  102. transition: this.transition,
  103. origin: 'top right',
  104. right: true,
  105. value: this.isActive,
  106. closeOnClick: !this.persistent,
  107. closeOnContentClick: false,
  108. lazy: this.lazy,
  109. light: this.light,
  110. dark: this.dark
  111. },
  112. on: {
  113. input: function input(val) {
  114. return _this3.isActive = val;
  115. }
  116. }
  117. }, [h('a', {
  118. slot: 'activator'
  119. }, this.$slots.default), this.genContent(), this.large ? this.genActions() : null]);
  120. }
  121. };
  122. // Utils
  123. // Mixins
  124. //# sourceMappingURL=VEditDialog.js.map