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

Add domain frequencies to validation report #47

Merged
merged 67 commits into from
Mar 25, 2024
Merged
Changes from 1 commit
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
7abdfca
Hover state of "logo" el
akuny Mar 8, 2024
7341628
Add about and card component/macro
akuny Mar 11, 2024
d31514b
Update 4xx templates
akuny Mar 11, 2024
95011ee
Add data checklist view
akuny Mar 11, 2024
550af85
Mapping index
akuny Mar 12, 2024
2efa8d0
Isolate alpine component for testing
akuny Mar 12, 2024
76856c5
Test MappingForm component and validation logic
akuny Mar 13, 2024
e3aeddc
Add linting, update ci action
akuny Mar 13, 2024
8d0cde3
Update actions
akuny Mar 13, 2024
d7b624f
Adopt convention of using calling parenthesis when using alpine.js co…
akuny Mar 13, 2024
e1c0c3f
Work on create mapping form
akuny Mar 13, 2024
e45df5b
Merge branch 'main' into mapping-ui
akuny Mar 13, 2024
816c6fb
Update sidebar
akuny Mar 13, 2024
3b0aa80
Stub out routes for data submissions CRUD
akuny Mar 13, 2024
c996a37
Work on create mapping use case
akuny Mar 13, 2024
5c062e2
Add show get_by_id method to map repo
akuny Mar 14, 2024
dcf5f74
Add use case to get a column map entity
akuny Mar 14, 2024
5712f63
Trying to tighten up consistency of terminology re ColumnMap entity
akuny Mar 14, 2024
fc4d444
Start working on display of existing column_maps
akuny Mar 14, 2024
493202c
Fix language inconsistencies
akuny Mar 14, 2024
793a486
Tweak formatting of component
akuny Mar 14, 2024
dabd742
First pass at mapping validation
akuny Mar 14, 2024
1598c4f
Test mapping validation logic
akuny Mar 14, 2024
1147f8a
Format
akuny Mar 14, 2024
d9a7db6
Fixes after manual testing
akuny Mar 15, 2024
a3d029e
Create mapping happy path
akuny Mar 15, 2024
a7ec3b0
Work on show mapping
akuny Mar 15, 2024
03b6df6
Stub out form that can update a required field, edit an optional fiel…
akuny Mar 18, 2024
372a500
Work on forms
akuny Mar 18, 2024
4191e9a
Successfully use form
akuny Mar 18, 2024
cafc16a
Testing and tweaking formatting
akuny Mar 18, 2024
cbca71e
Adjusting formatting
akuny Mar 19, 2024
82706db
Adjust button container
akuny Mar 19, 2024
be9d816
Update font of data type in checklist\
akuny Mar 19, 2024
4e9d14f
Hack to allow for space at bottom of mapping form
akuny Mar 19, 2024
e2675ec
Use card component in data submission show template
akuny Mar 19, 2024
9eae1ed
Pull tweaks into component files
akuny Mar 19, 2024
6637a4d
Update seed script, fix storage download_temp method
akuny Mar 19, 2024
a83ea32
Format login page
akuny Mar 19, 2024
7da9649
Test, lint and format
akuny Mar 19, 2024
b350336
Show created date in mapping index
akuny Mar 19, 2024
35d1c39
Move required fields to static prop of ColumnMap entity
akuny Mar 21, 2024
0b9e7ad
Shift add form to show.html
akuny Mar 22, 2024
4cb870c
Rework edit form
akuny Mar 22, 2024
933c366
Testing workflow
akuny Mar 22, 2024
ac04b33
Repositioning buttons
akuny Mar 22, 2024
03d63c2
Update type of component
akuny Mar 22, 2024
83ec6d6
Lint and format
akuny Mar 22, 2024
30db818
Test column map use cases
akuny Mar 22, 2024
a6f2747
Rename domain dir core to avoid confusion with gis terminology
akuny Mar 22, 2024
5e7a991
Tweak pending items
akuny Mar 22, 2024
2e53ebe
Add domain frequencies to validation report
Mar 22, 2024
82118fc
Update column_map route handlers
akuny Mar 25, 2024
4d14d4c
Remove hidden PUT fields and hook
akuny Mar 25, 2024
30aedad
Display user feedback for invalid mappings
akuny Mar 25, 2024
ded964c
Display updated date for mappings
akuny Mar 25, 2024
1e7c297
Add rudimentary required field indicator to edit form
akuny Mar 25, 2024
1e6d48c
Initialize report to empty list
akuny Mar 25, 2024
ad82729
Format
akuny Mar 25, 2024
2926c6c
Ad updated_at to fake column map repo
akuny Mar 25, 2024
ce94313
Basic test for column_map index method
akuny Mar 25, 2024
2fa2be4
Extract file reading to application layer from controller
akuny Mar 25, 2024
09c90ef
Merge in main
akuny Mar 25, 2024
cd957bb
Update import statement
akuny Mar 25, 2024
d8376b2
Test and lint frontend code
akuny Mar 25, 2024
45ce15c
Merge pull request #48 from GSA-TTS/mapping-ui
akuny Mar 25, 2024
d201e87
Merge in main
akuny Mar 25, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix language inconsistencies
  • Loading branch information
akuny committed Mar 14, 2024
commit 493202cad76000a7d50f3793d1c90a1f4af0ebc4
10 changes: 5 additions & 5 deletions nad_ch/controllers/web/routes/column_maps.py
Original file line number Diff line number Diff line change
@@ -31,11 +31,11 @@ def index():
@column_maps_bp.route("/column-maps/create")
@login_required
def create():
if "title" not in request.args:
if "name" not in request.args:
abort(404)

title = request.args.get("title")
return render_template("column-maps/create.html", title=title)
name = request.args.get("name")
return render_template("column-maps/create.html", name=name)


@column_maps_bp.route("/column-maps", methods=["POST"])
@@ -49,11 +49,11 @@ def store():
flash("No selected file")
return redirect(request.url)
if file:
title = request.form.get("title")
name = request.form.get("name")
content = file.read()
mapping_string = content.decode('utf-8')

view_model = add_column_map(g.ctx, current_user.id, title, mapping_string)
view_model = add_column_map(g.ctx, current_user.id, name, mapping_string)

return redirect(url_for("column_maps/show.html", column_map=view_model))

12 changes: 6 additions & 6 deletions nad_ch/controllers/web/src/components/MappingForm.ts
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
import { BASE_URL } from '../config';
import { getMappingTitleValidationError } from '../formValidation';
import { getMappingNameValidationError } from '../formValidation';
import { navigateTo } from '../utilities';

export default function MappingForm(): {
hasError: boolean;
errorMessage: string;
title: string;
name: string;
createMapping: () => void;
closeModal: () => void;
} {
return {
hasError: false,
errorMessage: '',
title: '',
name: '',
createMapping(): void {
this.hasError = false;

const validationError = getMappingTitleValidationError(this.title);
const validationError = getMappingNameValidationError(this.name);

if (validationError) {
this.hasError = true;
this.errorMessage = validationError;
} else {
navigateTo(
`${BASE_URL}/mappings/create?title=${encodeURIComponent(this.title)}`,
`${BASE_URL}/mappings/create?name=${encodeURIComponent(this.name)}`,
);
}
},
closeModal(): void {
this.title = '';
this.name = '';
this.hasError = false;
this.errorMessage = '';
const button: HTMLElement | null =
26 changes: 13 additions & 13 deletions nad_ch/controllers/web/src/formValidation.spec.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
import { getMappingTitleValidationError } from './formValidation';
import { getMappingNameValidationError } from './formValidation';

describe('getMappingTitleValidationError', () => {
test('returns error message if title is empty', () => {
const result = getMappingTitleValidationError('');
describe('getMappingNameValidationError', () => {
test('returns error message if name is empty', () => {
const result = getMappingNameValidationError('');
expect(result).toBe('Mapping name is required');
});

test('returns error message if title is longer than 25 characters', () => {
const longTitle = 'a'.repeat(26);
const result = getMappingTitleValidationError(longTitle);
test('returns error message if name is longer than 25 characters', () => {
const longName = 'a'.repeat(26);
const result = getMappingNameValidationError(longName);
expect(result).toBe('Enter less than 25 letters or numbers');
});

test('returns errormessage if title contains invalid characters', () => {
const invalidTitle = 'test@123';
const result = getMappingTitleValidationError(invalidTitle);
test('returns errormessage if name contains invalid characters', () => {
const invalidName = 'test@123';
const result = getMappingNameValidationError(invalidName);
expect(result).toBe('Name can only contain letters and numbers');
});

test('returns null for a valid title', () => {
const validTitle = 'ValidTitle123';
const result = getMappingTitleValidationError(validTitle);
test('returns null for a valid name', () => {
const validName = 'ValidName123';
const result = getMappingNameValidationError(validName);
expect(result).toBeNull();
});
});
8 changes: 4 additions & 4 deletions nad_ch/controllers/web/src/formValidation.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
export function getMappingTitleValidationError(title: string): string | null {
if (title === '') {
export function getMappingNameValidationError(name: string): string | null {
if (name === '') {
return 'Mapping name is required';
} else if (title.length > 25) {
} else if (name.length > 25) {
return 'Enter less than 25 letters or numbers';
} else if (/[^a-zA-Z0-9]/.test(title)) {
} else if (/[^a-zA-Z0-9]/.test(name)) {
return 'Name can only contain letters and numbers';
}
return null;
4 changes: 2 additions & 2 deletions nad_ch/controllers/web/templates/column_maps/create.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{% extends "_layouts/base.html" %} {% block title %}Mappings{% endblock %} {%
from "components/page-header.html" import page_header %} {% block content %} {{
page_header("Create " ~ title) }}
page_header("Create " ~ name) }}

<ol class="usa-process-list">
<li class="usa-process-list__item">
@@ -28,7 +28,7 @@ <h4 class="usa-process-list__heading">Upload mapping</h4>
required
/>

<input type="hidden" name="title" value="{{ title }}" />
<input type="hidden" name="name" value="{{ name }}" />
</div>

{% with messages = get_flashed_messages() %} {% if messages %}
2 changes: 1 addition & 1 deletion nad_ch/controllers/web/templates/column_maps/index.html
Original file line number Diff line number Diff line change
@@ -51,7 +51,7 @@ <h2 class="usa-modal__heading" id="mapping-modal-heading">
type="text"
id="mapping-name"
name="mapping-name"
x-model="title"
x-model="name"
/>
<br />
<span