Skip to content

Commit

Permalink
fix: prototype duplicate prevention
Browse files Browse the repository at this point in the history
  • Loading branch information
ChinHairSaintClair committed Nov 6, 2024
1 parent 63a2660 commit e266863
Show file tree
Hide file tree
Showing 7 changed files with 375 additions and 3 deletions.
27 changes: 27 additions & 0 deletions webapp/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions webapp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@
"eurodigit": "^3.1.3",
"font-awesome": "^4.7.0",
"jquery": "3.5.1",
"levenshtein": "1.0.5",
"@types/levenshtein": "1.0.4",
"lodash-es": "^4.17.21",
"moment-locales-webpack-plugin": "^1.2.0",
"ngrx-store-logger": "^0.2.4",
Expand Down
5 changes: 5 additions & 0 deletions webapp/src/ts/components/enketo/enketo.component.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
<div [attr.id]="formId" class="enketo" [attr.data-editing]="editing">
<div class="container pages"></div>
<!-- Do not use inline styling -->
<div
id="duplicate_info"
style="display: none; width: 100%; min-height: 20px; padding-left: 20px; padding-right: 20px; background-color: #ffe7e8; color: #e33030;">
</div>
<div class="form-footer">
<button (click)="onCancel.emit()" class="btn btn-link cancel" [disabled]="status?.saving">{{'Cancel' | translate}}</button>
<div class="loader inline small" *ngIf="status?.saving"></div>
Expand Down
17 changes: 17 additions & 0 deletions webapp/src/ts/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,22 @@ window.startupTimes.firstCodeExecution = performance.now();

window.PouchDB = require('pouchdb-browser').default;
window.$ = window.jQuery = require('jquery');
window._phdcChanges = {
hierarchyDuplicatePrevention: {
health_center: {
...Levenshtein,
props: [
{form_prop_path: `/data/health_center/name`, db_doc_ref: 'name'},
{form_prop_path: '/data/health_center/external_id', db_doc_ref: 'external_id'}
],
queryParams: {
valuePaths: ['/data/health_center/is_user_flagged_duplicate', '/data/health_center/duplicate/action'],
// eslint-disable-next-line eqeqeq
query: (duplicate, action) => duplicate === 'yes' && action != null
}
}
}
};

import { enableProdMode } from '@angular/core';
import '@angular/compiler';
Expand All @@ -19,6 +35,7 @@ import { environment } from '@mm-environments/environment';
import { POUCHDB_OPTIONS } from './constants';

import * as bootstrapper from '../js/bootstrapper';
import { Levenshtein } from './polyfills';

// Moment additional locales
require('../js/moment-locales/tl');
Expand Down
Loading

0 comments on commit e266863

Please sign in to comment.