From 83967e6ed9fa84989a4336c53ee66d2b9384aa31 Mon Sep 17 00:00:00 2001 From: leigh-mil Date: Tue, 22 Oct 2019 14:30:34 -0400 Subject: [PATCH] Delete unused component and macro --- js/components/forms/multi_step_modal_form.js | 2 - js/components/selector.js | 117 ------------------ js/index.js | 2 - templates/components/selector.html | 98 --------------- .../portfolios/fragments/change_ppoc.html | 1 - 5 files changed, 220 deletions(-) delete mode 100644 js/components/selector.js delete mode 100644 templates/components/selector.html diff --git a/js/components/forms/multi_step_modal_form.js b/js/components/forms/multi_step_modal_form.js index 3ef31b81..968e20cb 100644 --- a/js/components/forms/multi_step_modal_form.js +++ b/js/components/forms/multi_step_modal_form.js @@ -2,7 +2,6 @@ import FormMixin from '../../mixins/form' import textinput from '../text_input' import optionsinput from '../options_input' import checkboxinput from '../checkbox_input' -import Selector from '../selector' import Modal from '../../mixins/modal' import toggler from '../toggler' @@ -14,7 +13,6 @@ export default { components: { toggler, Modal, - Selector, textinput, optionsinput, checkboxinput, diff --git a/js/components/selector.js b/js/components/selector.js deleted file mode 100644 index 06c1bc63..00000000 --- a/js/components/selector.js +++ /dev/null @@ -1,117 +0,0 @@ -import { VPopover } from 'v-tooltip' - -const SelectorInput = { - name: 'SelectorInput', - props: { - name: String, - value: String, - label: String, - description: String, - selected: Boolean, - handleChange: Function, - handleEnter: Function, - handleEsc: Function, - }, - - computed: { - id: function() { - return `${this.name}_${this.value}` - }, - }, - - methods: { - onChange: function(e) { - this.handleChange(this.value) - }, - - onEnter: function(e) { - this.handleEnter() - }, - - onEsc: function(e) { - this.handleEsc() - }, - }, -} - -export default { - name: 'selector', - - components: { - VPopover, - SelectorInput, - }, - - props: { - choices: Array, - defaultLabel: String, - initialErrors: Array, - initialChoice: { - type: String, - default: null, - }, - }, - - data: function() { - return { - value: this.initialChoice || null, - currentChoice: this.initialChoice || null, - showError: (this.initialErrors && this.initialErrors.length) || false, - usingKeyboard: false, - } - }, - - computed: { - label: function() { - if (this.value) { - const selectedChoice = this.choices.find(choice => { - return this.value === choice[0] - })[1] - return selectedChoice.name - } else { - return this.defaultLabel - } - }, - }, - - methods: { - change: function(value) { - this.value = value - this.showError = false - }, - - onShow: function() { - setTimeout(() => { - // timeout is a hack to make focus work in Chrome - const selected = this.$refs.choices.find(choice => choice.selected) - if (selected) { - selected.$refs.input[0].focus() - } else { - this.$refs.choices[0].$refs.input[0].focus() - } - }, 100) - }, - - enter: function() { - this.$refs.popover.hide() - }, - - esc: function() { - this.value = this.currentChoice - this.usingKeyboard = false - this.$refs.popover.hide() - }, - - handleEnterOption: function(e) { - this.change(e.target.value) - this.currentChoice = e.target.value - this.usingKeyboard = false - this.$refs.popover.hide() - }, - - handleButtonArrowDown: function(e) { - this.usingKeyboard = true - this.$refs.popover.show() - }, - }, -} diff --git a/js/index.js b/js/index.js index 575006d4..b1fbca9f 100644 --- a/js/index.js +++ b/js/index.js @@ -19,7 +19,6 @@ import ApplicationEnvironments from './components/forms/new_application/environm import MultiStepModalForm from './components/forms/multi_step_modal_form' import uploadinput from './components/upload_input' import Modal from './mixins/modal' -import selector from './components/selector' import BudgetChart from './components/charts/budget_chart' import SpendTable from './components/tables/spend_table' import LocalDatetime from './components/local_datetime' @@ -52,7 +51,6 @@ const app = new Vue({ poc, ApplicationNameAndDescription, ApplicationEnvironments, - selector, BudgetChart, SpendTable, LocalDatetime, diff --git a/templates/components/selector.html b/templates/components/selector.html deleted file mode 100644 index 1b0181a3..00000000 --- a/templates/components/selector.html +++ /dev/null @@ -1,98 +0,0 @@ -{% from "components/icon.html" import Icon %} - -{# expects a wtforms SelectField instance #} -{% macro Selector(field, default_label='Select an option') -%} - - - -
- - -
{{ field.label | striptags }}
- - {% if field.description %} -

- {{ field.description | safe }} -

- {% endif %} - - {{ Icon('alert',classes="icon-validation") }} -
- - - - {{ Icon('alert',classes="icon-validation") }} - - - - - - -
-
-
- -{%- endmacro %} diff --git a/templates/portfolios/fragments/change_ppoc.html b/templates/portfolios/fragments/change_ppoc.html index eef989cc..7500e20d 100644 --- a/templates/portfolios/fragments/change_ppoc.html +++ b/templates/portfolios/fragments/change_ppoc.html @@ -1,5 +1,4 @@ {% from "components/icon.html" import Icon %} -{% from "components/selector.html" import Selector %} {% from "components/text_input.html" import TextInput %} {% from "components/multi_step_modal_form.html" import MultiStepModalForm %} {% from "components/alert.html" import Alert %}