diff --git a/.secrets.baseline b/.secrets.baseline index 3e7ecf38..9bb34b58 100644 --- a/.secrets.baseline +++ b/.secrets.baseline @@ -3,7 +3,7 @@ "files": "^.secrets.baseline$", "lines": null }, - "generated_at": "2019-09-24T13:51:51Z", + "generated_at": "2019-09-25T09:43:11Z", "plugins_used": [ { "base64_limit": 4.5, @@ -199,5 +199,5 @@ } ] }, - "version": "0.12.5" + "version": "0.12.6" } diff --git a/js/components/__tests__/edit_environment_role.test.js b/js/components/__tests__/edit_environment_role.test.js deleted file mode 100644 index 763db4a5..00000000 --- a/js/components/__tests__/edit_environment_role.test.js +++ /dev/null @@ -1,96 +0,0 @@ -import { shallowMount } from '@vue/test-utils' -import { NO_ACCESS, EditEnvironmentRole } from '../forms/edit_environment_role' - -describe('EditEnvironmentRole', () => { - var initialRoleCategories, wrapper - - beforeEach(() => { - initialRoleCategories = [ - { - role: NO_ACCESS, - members: [ - { role_name: null, application_role_id: '123' }, - { role_name: null, application_role_id: '456' }, - ], - }, - { - role: 'Basic Access', - members: [{ role_name: 'Basic Access', application_role_id: '789' }], - }, - { - role: 'Network Admin', - members: [], - }, - { - role: 'Business Read-only', - members: [ - { role_name: 'Business Read-only', application_role_id: '012' }, - { role_name: 'Business Read-only', application_role_id: '345' }, - ], - }, - { - role: 'Technical Read-only', - members: [ - { role_name: 'Technical Read-only', application_role_id: '678' }, - ], - }, - ] - - wrapper = shallowMount(EditEnvironmentRole, { - propsData: { initialRoleCategories }, - }) - }) - - it('removes null roles to no_access', () => { - let roles = wrapper.vm.sanitizeValues([ - { role: NO_ACCESS, members: [{ role_name: null }] }, - ]) - expect(roles).toEqual([ - { role: NO_ACCESS, members: [{ role_name: NO_ACCESS }] }, - ]) - }) - - it('gets the data for a user', () => { - let member_data = wrapper.vm.getUserInfo('678') - - expect(member_data).toEqual({ - role_name: 'Technical Read-only', - application_role_id: '678', - }) - }) - - it('removes a user from role', () => { - let techRole = wrapper.vm.roleCategories.find(role => { - return role.role === 'Technical Read-only' - }) - - expect(techRole.members.length).toEqual(1) - wrapper.vm.removeUser('678') - expect(techRole.members.length).toEqual(0) - }) - - it('adds user to a role', () => { - let techRole = wrapper.vm.roleCategories.find(role => { - return role.role === 'Technical Read-only' - }) - - expect(techRole.members.length).toEqual(1) - wrapper.vm.addUser({ application_role_id: '901' }, 'Technical Read-only') - expect(techRole.members.length).toEqual(2) - }) - - it('updates users role', () => { - let techRole = wrapper.vm.roleCategories.find(role => { - return role.role === 'Technical Read-only' - }) - let businessRole = wrapper.vm.roleCategories.find(role => { - return role.role === 'Business Read-only' - }) - - expect(techRole.members.length).toEqual(1) - expect(businessRole.members.length).toEqual(2) - wrapper.vm.updateRoles('678', 'Business Read-only') - expect(techRole.members.length).toEqual(0) - expect(businessRole.members.length).toEqual(3) - }) -}) diff --git a/js/components/forms/__tests__/edit_officer_form.test.js b/js/components/forms/__tests__/edit_officer_form.test.js deleted file mode 100644 index 18f36ffc..00000000 --- a/js/components/forms/__tests__/edit_officer_form.test.js +++ /dev/null @@ -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) - }) -}) diff --git a/js/components/forms/base_form.js b/js/components/forms/base_form.js index 77bc0099..7dd9ad81 100644 --- a/js/components/forms/base_form.js +++ b/js/components/forms/base_form.js @@ -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, diff --git a/js/components/forms/edit_application_roles.js b/js/components/forms/edit_application_roles.js deleted file mode 100644 index ef5de676..00000000 --- a/js/components/forms/edit_application_roles.js +++ /dev/null @@ -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) - }, - }, -} diff --git a/js/components/forms/edit_environment_role.js b/js/components/forms/edit_environment_role.js deleted file mode 100644 index c823758f..00000000 --- a/js/components/forms/edit_environment_role.js +++ /dev/null @@ -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') - }, -} diff --git a/js/components/forms/edit_officer_form.js b/js/components/forms/edit_officer_form.js deleted file mode 100644 index 016187bc..00000000 --- a/js/components/forms/edit_officer_form.js +++ /dev/null @@ -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: '
', -} diff --git a/js/components/forms/funding.js b/js/components/forms/funding.js deleted file mode 100644 index 8e4497a6..00000000 --- a/js/components/forms/funding.js +++ /dev/null @@ -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() - }, -} diff --git a/js/components/forms/oversight.js b/js/components/forms/oversight.js deleted file mode 100644 index 2516fad1..00000000 --- a/js/components/forms/oversight.js +++ /dev/null @@ -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, - } - }, -} diff --git a/js/components/forms/to_form.js b/js/components/forms/to_form.js index 9fe18b27..804a0fa3 100644 --- a/js/components/forms/to_form.js +++ b/js/components/forms/to_form.js @@ -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, }, diff --git a/js/components/levelofwarrant.js b/js/components/levelofwarrant.js deleted file mode 100644 index d46e489c..00000000 --- a/js/components/levelofwarrant.js +++ /dev/null @@ -1,27 +0,0 @@ -import textinput from './text_input' -import checkboxinput from './checkbox_input' -import FormMixin from '../mixins/form' - -export default { - mixins: [FormMixin], - - components: { - textinput, - checkboxinput, - }, - - props: { - initialData: { - type: Object, - default: () => ({}), - }, - }, - - data() { - const { unlimited_level_of_warrant = false } = this.initialData - - return { - unlimited_level_of_warrant, - } - }, -} diff --git a/js/components/tables/task_order_list.js b/js/components/tables/task_order_list.js deleted file mode 100644 index d7353307..00000000 --- a/js/components/tables/task_order_list.js +++ /dev/null @@ -1,107 +0,0 @@ -import { set } from 'vue/dist/vue' -import { compose, sortBy, reverse, indexBy, prop, toLower } from 'ramda' - -import { formatDollars } from '../../lib/dollars' -import localDatetime from '../../components/local_datetime' - -const sort = (sortInfo, members) => { - if (sortInfo.columnName === '') { - return members - } else { - const sortColumn = sortInfo.columns[sortInfo.columnName] - const sortedMembers = sortColumn.sortFunc(sortColumn.attr, members) - - return sortInfo.isAscending ? sortedMembers : reverse(sortedMembers) - } -} - -export default { - name: 'task-order-list', - - props: { - data: Array, - expired: Boolean, - funded: Boolean, - }, - - components: { - localDatetime, - }, - - data: function() { - const alphabeticalSort = (attr, members) => { - const lowercaseProp = compose( - toLower, - prop(attr) - ) - return sortBy(lowercaseProp, members) - } - - const numericSort = (attr, members) => sortBy(prop(attr), members) - const columns = [ - { - displayName: 'Status', - attr: 'display_status', - }, - { - displayName: 'Period of Performance', - attr: 'start_date', - sortFunc: numericSort, - width: '50%', - class: 'period-of-performance', - }, - { - displayName: 'Initial Value', - attr: 'budget', - class: 'table-cell--align-right', - sortFunc: numericSort, - }, - { - displayName: this.expired ? 'Expired Balance' : 'Balance', - attr: 'budget', - class: 'table-cell--align-right', - sortFunc: numericSort, - }, - { - displayName: '', - }, - ] - - const defaultSortColumn = 'Period of Performance' - return { - sortInfo: { - columnName: defaultSortColumn, - isAscending: false, - columns: indexBy(prop('displayName'), columns), - }, - days_to_exp_alert_limit: 30, - } - }, - - computed: { - taskOrders: function() { - return sort(this.sortInfo, this.data) - }, - }, - - methods: { - updateSort: function(columnName) { - // clicking a column twice toggles ascending / descending - if (columnName === this.sortInfo.columnName) { - this.sortInfo.isAscending = !this.sortInfo.isAscending - } - - this.sortInfo.columnName = columnName - }, - - getColumns: function() { - return Object.values(this.sortInfo.columns) - }, - - formatDollars: function(value) { - return formatDollars(value, false) - }, - }, - - template: '', -} diff --git a/js/components/toggler.js b/js/components/toggler.js index 225e144b..0b68a97f 100644 --- a/js/components/toggler.js +++ b/js/components/toggler.js @@ -1,8 +1,6 @@ -import { EditEnvironmentRole } from './forms/edit_environment_role' import FormMixin from '../mixins/form' import optionsinput from './options_input' import textinput from './text_input' -import EnvironmentRole from './environment_role' export default { name: 'toggler', @@ -17,11 +15,9 @@ export default { }, components: { - EditEnvironmentRole, optionsinput, textinput, optionsinput, - EnvironmentRole, toggler: this, }, diff --git a/js/components/totals_box.js b/js/components/totals_box.js deleted file mode 100644 index 8ce5fb49..00000000 --- a/js/components/totals_box.js +++ /dev/null @@ -1,26 +0,0 @@ -import { formatDollars } from '../lib/dollars' - -export default { - name: 'totalsbox', - - props: { - name: String, - obligated: Number, - contractAmount: Number, - }, - - computed: { - formattedObligated: function() { - return formatDollars(this._filterNaN(this.obligated)) - }, - formattedContractAmount: function() { - return formatDollars(this._filterNaN(this.contractAmount)) - }, - }, - - methods: { - _filterNaN: function(value) { - return Number.isNaN(value) ? 0 : value - }, - }, -} diff --git a/js/index.js b/js/index.js index ddabd527..c17bcbc2 100644 --- a/js/index.js +++ b/js/index.js @@ -8,28 +8,21 @@ import VTooltip from 'v-tooltip' import stickybits from 'stickybits' import dodlogin from './components/dodlogin' -import levelofwarrant from './components/levelofwarrant' import optionsinput from './components/options_input' import multicheckboxinput from './components/multi_checkbox_input' import textinput from './components/text_input' import checkboxinput from './components/checkbox_input' -import EditOfficerForm from './components/forms/edit_officer_form' import poc from './components/forms/poc' -import oversight from './components/forms/oversight' import toggler from './components/toggler' import ApplicationNameAndDescription from './components/forms/new_application/name_and_description' import ApplicationEnvironments from './components/forms/new_application/environments' -import { EditEnvironmentRole } from './components/forms/edit_environment_role' -import EditApplicationRoles from './components/forms/edit_application_roles' import MultiStepModalForm from './components/forms/multi_step_modal_form' -import funding from './components/forms/funding' 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 EnvironmentsTable from './components/tables/application_environments' -import TaskOrderList from './components/tables/task_order_list.js' import LocalDatetime from './components/local_datetime' import { isNotInVerticalViewport } from './lib/viewport' import DateSelector from './components/date_selector' @@ -39,7 +32,6 @@ import DeleteConfirmation from './components/delete_confirmation' import NewEnvironment from './components/forms/new_environment' import EnvironmentRole from './components/environment_role' import SemiCollapsibleText from './components/semi_collapsible_text' -import TotalsBox from './components/totals_box' import ToForm from './components/forms/to_form' import ClinFields from './components/clin_fields' @@ -54,35 +46,27 @@ const app = new Vue({ components: { dodlogin, toggler, - levelofwarrant, optionsinput, multicheckboxinput, textinput, checkboxinput, poc, - oversight, ApplicationNameAndDescription, ApplicationEnvironments, selector, BudgetChart, SpendTable, EnvironmentsTable, - TaskOrderList, LocalDatetime, - EditEnvironmentRole, - EditApplicationRoles, MultiStepModalForm, - funding, uploadinput, DateSelector, - EditOfficerForm, SidenavToggler, BaseForm, DeleteConfirmation, NewEnvironment, EnvironmentRole, SemiCollapsibleText, - TotalsBox, ToForm, ClinFields, },