Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor Vue Single File Components #193

Merged
merged 14 commits into from Nov 10, 2023
Merged

Refactor Vue Single File Components #193

merged 14 commits into from Nov 10, 2023

Conversation

NathanWEdwards
Copy link
Collaborator

@NathanWEdwards NathanWEdwards commented Jul 21, 2023

This request moves several methods shared between Vue SFC's into utils.js.

This request also adds test support; replaces the datetime manipulation library, Moment, with DayJS; does not display parentheses next to arrest citation, disposition, and offense dates on the popup page; and sets a max date to the current day users can input in date fields.

Several Vue components share method names with the same functionality. The following Vue method definitions shared between components/filings.vue, components/manage-counts.vue, and components/popup.vue have been moved into utils.js:

  • autoExpand
  • clearAll
  • confirmDeleteCount
  • confirmClearData
  • countyCodeFromCounty
  • countyNameFromCountyCode
  • createFilingsFromCounts
  • csvData
  • dateFormatSimple
  • deleteCount
  • detectChangesInChromeStorage
  • devLog
  • getError
  • getNextNotaryDate
  • handleNewDocketNums
  • handlePrintMacro
  • initAfterFilingRefresh
  • initAfterVue
  • initScrollDetection
  • initSmoothScroll
  • initTextAreaAutoExpand
  • loadAll
  • linesBreaksFromArray
  • lowercase
  • makeFilingObject
  • maxDate
  • openManagePage
  • pluralize
  • nl2br
  • openPetitionsPage
  • resetSettings
  • saveCounts
  • saveHtml
  • saveResponses
  • saveSettings
  • setInitialExpandForTextAreas
  • sinceNow
  • slugify
  • stringAgeInYearsAtDate
  • toCountyCode
  • todayDate
  • uppercase

Several functions are present as Vue methods in components, but are only called by other Vue component methods. These helper functions that are present in multiple components have been moved into utils.js:

  • allDocketNumsObject
  • allDocketSheetNumsObject
  • csvFilename
  • filingNameFromType
  • filterAndMakeFilingObject
  • groupByCounty
  • groupByFilingType
  • groupCountsByMaxDocketNumber
  • isEligible
  • isFileable
  • isSupported
  • isStipulated
  • offenseAbbreviationToFull

Chai, Mocha, and Puppeteer have been added as development dependencies for test. The test NPM script has been added that invokes the following command, node ./node_modules/mocha/bin/mocha.js --require mocha-fixtures.mjs --config .mocharc.js **/*.spec.mjs.

A test directory has been added in the project root directory. Test utility methods and selectors are located in test-utils.mjs. A single set of tests have been added to validate the presence of image logos and the terms of service checkbox on the app's popup. When tests are run a screenshots directory is created if the directory does not exist and test screenshots are output to this directory. Due to limitations with Puppeteer and the Chromium API, additional effort is needed for introducing additional tests.

@NathanWEdwards NathanWEdwards changed the title Move methods out of Vue SFC files. Refactor Vue Single File Components Jul 21, 2023
@NathanWEdwards NathanWEdwards merged commit 95a1bab into m3-jod Nov 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant