Delete unused Vue components and remove references to them.

This commit is contained in:
dandds
2019-09-25 06:14:12 -04:00
parent 494978fabd
commit 6dc1e10e77
15 changed files with 2 additions and 654 deletions

View File

@@ -1,43 +0,0 @@
import { shallowMount } from '@vue/test-utils'
import EditOfficerForm from '../edit_officer_form'
describe('EditOfficerForm', () => {
it('defaults to not editing', () => {
const wrapper = shallowMount(EditOfficerForm)
expect(wrapper.vm.$data.editing).toEqual(false)
})
it('does not start in editing mode when no errors', () => {
const wrapper = shallowMount(EditOfficerForm, {
propsData: { hasErrors: false },
})
expect(wrapper.vm.$data.editing).toEqual(false)
})
it('does start in editing mode when the form has errors', () => {
const wrapper = shallowMount(EditOfficerForm, {
propsData: { hasErrors: true },
})
expect(wrapper.vm.$data.editing).toEqual(true)
})
it('does start in editing mode when the form has changes', () => {
const wrapper = shallowMount(EditOfficerForm, {
propsData: { hasChanges: true },
})
expect(wrapper.vm.$data.editing).toEqual(true)
})
it('starts editing when edit method called', () => {
const wrapper = shallowMount(EditOfficerForm)
wrapper.vm.edit({ preventDefault: () => null })
expect(wrapper.vm.$data.editing).toEqual(true)
})
it('stops editing when cancel method called', () => {
const wrapper = shallowMount(EditOfficerForm)
wrapper.vm.cancel()
expect(wrapper.vm.$data.editing).toEqual(false)
})
})

View File

@@ -6,7 +6,6 @@ import FormMixin from '../../mixins/form'
import Modal from '../../mixins/modal'
import MultiStepModalForm from './multi_step_modal_form'
import checkboxinput from '../checkbox_input'
import levelofwarrant from '../levelofwarrant'
import multicheckboxinput from '../multi_checkbox_input'
import optionsinput from '../options_input'
import SemiCollapsibleText from '../semi_collapsible_text'
@@ -22,7 +21,6 @@ export default {
Modal,
MultiStepModalForm,
checkboxinput,
levelofwarrant,
multicheckboxinput,
optionsinput,
SemiCollapsibleText,

View File

@@ -1,26 +0,0 @@
import FormMixin from '../../mixins/form'
import Modal from '../../mixins/modal'
import toggler from '../toggler'
import { EditEnvironmentRole } from './edit_environment_role'
export default {
name: 'edit-application-roles',
mixins: [FormMixin, Modal],
components: {
toggler,
EditEnvironmentRole,
},
props: {
name: String,
id: String,
},
methods: {
doRevoke: function() {
this.$root.$emit('revoke-' + this.id)
},
},
}

View File

@@ -1,98 +0,0 @@
import FormMixin from '../../mixins/form'
import Modal from '../../mixins/modal'
// Note: If refactoring consider using nested vue components as suggested by Dan:
// https://github.com/dod-ccpo/atst/pull/799/files#r282240663
// May also want to reconsider the data structure by storing the roles and members separately
export const NO_ACCESS = 'No Access'
export const EditEnvironmentRole = {
name: 'edit-environment-role',
mixins: [FormMixin],
props: {
initialRoleCategories: Array,
},
data: function() {
return {
selectedSection: null,
roleCategories: this.sanitizeValues(this.initialRoleCategories),
}
},
methods: {
sanitizeValues: function(roles) {
roles.forEach(role => {
role.members.forEach(member => {
if (member.role_name === null) {
member.role_name = NO_ACCESS
}
})
})
return roles
},
checkNoAccess: function(role) {
return role === NO_ACCESS
},
toggleSection: function(sectionName) {
if (this.selectedSection === sectionName) {
this.selectedSection = null
} else {
this.selectedSection = sectionName
}
},
onInput: function(e) {
this.changed = true
this.updateRoles(e.target.attributes['user-id'].value, e.target.value)
this.showError = false
this.showValid = true
},
getUserInfo: function(userId) {
for (let role of this.roleCategories) {
for (let member of role.members) {
if (member.application_role_id === userId) {
return member
}
}
}
},
removeUser: function(userId) {
for (let role of this.roleCategories) {
role.members = role.members.filter(member => {
return member.application_role_id !== userId
})
if (!role.members) {
role.members = []
}
}
},
addUser: function(userInfo, newRole) {
this.roleCategories.forEach(role => {
if (role.role === newRole) {
userInfo.role_name = newRole
role.members.push(userInfo)
}
})
},
updateRoles: function(userId, newRole) {
var userInfo = this.getUserInfo(userId)
this.removeUser(userId)
this.addUser(userInfo, newRole)
this.toggleSection()
},
},
render: function(createElement) {
return createElement('p', 'Please implement inline-template')
},
}

View File

@@ -1,44 +0,0 @@
import FormMixin from '../../mixins/form'
import checkboxinput from '../checkbox_input'
import textinput from '../text_input'
export default {
name: 'edit-officer-form',
mixins: [FormMixin],
components: {
checkboxinput,
textinput,
},
props: {
hasChanges: {
type: Boolean,
default: () => false,
},
hasErrors: {
type: Boolean,
default: () => false,
},
},
data: function() {
return {
editing: this.hasErrors || this.hasChanges,
}
},
methods: {
edit: function(event) {
event.preventDefault()
this.editing = true
},
cancel: function(event) {
this.editing = false
},
},
template: '<div></div>',
}

View File

@@ -1,81 +0,0 @@
import createNumberMask from 'text-mask-addons/dist/createNumberMask'
import { conformToMask } from 'vue-text-mask'
import FormMixin from '../../mixins/form'
import textinput from '../text_input'
import optionsinput from '../options_input'
import uploadinput from '../upload_input'
export default {
name: 'funding',
mixins: [FormMixin],
components: {
textinput,
optionsinput,
uploadinput,
},
props: {
initialData: {
type: Object,
default: () => ({}),
},
uploadErrors: {
type: Array,
default: () => [],
},
},
data: function() {
const {
clin_01 = 0,
clin_02 = 0,
clin_03 = 0,
clin_04 = 0,
} = this.initialData
return {
clin_01,
clin_02,
clin_03,
clin_04,
}
},
computed: {
totalBudget: function() {
return [this.clin_01, this.clin_02, this.clin_03, this.clin_04].reduce(
function(acc, curr) {
curr = !curr ? 0 : parseFloat(curr)
return acc + curr
},
0
)
},
totalBudgetStr: function() {
return this.totalBudget.toLocaleString('us-US', {
style: 'currency',
currency: 'USD',
})
},
},
methods: {
updateBudget: function() {
document.querySelector('#to-target').innerText = this.totalBudgetStr
},
},
watch: {
clin_01: 'updateBudget',
clin_02: 'updateBudget',
clin_03: 'updateBudget',
clin_04: 'updateBudget',
},
mounted: function() {
this.updateBudget()
},
}

View File

@@ -1,80 +0,0 @@
import FormMixin from '../../mixins/form'
import textinput from '../text_input'
import checkboxinput from '../checkbox_input'
const dodid = {
name: 'dodid',
mixins: [FormMixin],
components: {
textinput,
},
props: {
initialInvite: Boolean,
},
data: function() {
return {
invite: this.initialInvite,
}
},
}
const cordata = {
name: 'cordata',
mixins: [FormMixin],
components: {
textinput,
checkboxinput,
},
props: {
initialCorInvite: Boolean,
},
data: function() {
return {
cor_invite: this.initialCorInvite,
}
},
}
export default {
name: 'oversight',
mixins: [FormMixin],
components: {
textinput,
checkboxinput,
cordata,
dodid,
},
props: {
initialData: {
type: Object,
default: () => ({}),
},
},
data: function() {
const {
am_cor = false,
ko_invite = false,
cor_invite = false,
so_invite = false,
} = this.initialData
return {
am_cor,
ko_invite,
cor_invite,
so_invite,
}
},
}

View File

@@ -7,7 +7,6 @@ import FormMixin from '../../mixins/form'
import optionsinput from '../options_input'
import SemiCollapsibleText from '../semi_collapsible_text'
import textinput from '../text_input'
import TotalsBox from '../totals_box'
import uploadinput from '../upload_input'
export default {
@@ -22,7 +21,6 @@ export default {
optionsinput,
SemiCollapsibleText,
textinput,
TotalsBox,
uploadinput,
},