step1_controller.js 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /**
  2. * Licensed to the Apache Software Foundation (ASF) under one
  3. * or more contributor license agreements. See the NOTICE file
  4. * distributed with this work for additional information
  5. * regarding copyright ownership. The ASF licenses this file
  6. * to you under the Apache License, Version 2.0 (the
  7. * "License"); you may not use this file except in compliance
  8. * with the License. You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an "AS IS" BASIS,
  14. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. */
  18. var App = require('app');
  19. App.WidgetWizardStep1Controller = Em.Controller.extend({
  20. name: "widgetWizardStep1Controller",
  21. /**
  22. * Types:
  23. * - GAUGE
  24. * - NUMBER
  25. * - GRAPH
  26. * - TEMPLATE
  27. * @type {string}
  28. */
  29. widgetType: '',
  30. /**
  31. * @type {boolean}
  32. */
  33. isSubmitDisabled: function () {
  34. return !this.get('widgetType');
  35. }.property('widgetType'),
  36. /**
  37. * @type {App.WidgetType}
  38. */
  39. options: function () {
  40. var selectedType = this.get('widgetType');
  41. return App.WidgetType.find().map(function(option) {
  42. return {
  43. name: option.get('name'),
  44. displayName: option.get('displayName'),
  45. iconPath: option.get('iconPath'),
  46. description: option.get('description'),
  47. isSelected: option.get('name') == selectedType
  48. }
  49. });
  50. }.property('widgetType'),
  51. /**
  52. * choose widget type and proceed to the next step
  53. * @param {object} event
  54. */
  55. chooseOption: function (event) {
  56. this.set('widgetType', event.context);
  57. this.next();
  58. },
  59. loadStep: function () {
  60. this.clearStep();
  61. },
  62. clearStep: function () {
  63. this.set('widgetType', '');
  64. },
  65. next: function () {
  66. App.router.send('next');
  67. }
  68. });