Skip to content

Commit e266863

Browse files
fix: prototype duplicate prevention
1 parent 63a2660 commit e266863

File tree

7 files changed

+375
-3
lines changed

7 files changed

+375
-3
lines changed

webapp/package-lock.json

+27
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

webapp/package.json

+2
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@
4848
"eurodigit": "^3.1.3",
4949
"font-awesome": "^4.7.0",
5050
"jquery": "3.5.1",
51+
"levenshtein": "1.0.5",
52+
"@types/levenshtein": "1.0.4",
5153
"lodash-es": "^4.17.21",
5254
"moment-locales-webpack-plugin": "^1.2.0",
5355
"ngrx-store-logger": "^0.2.4",

webapp/src/ts/components/enketo/enketo.component.html

+5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
<div [attr.id]="formId" class="enketo" [attr.data-editing]="editing">
22
<div class="container pages"></div>
3+
<!-- Do not use inline styling -->
4+
<div
5+
id="duplicate_info"
6+
style="display: none; width: 100%; min-height: 20px; padding-left: 20px; padding-right: 20px; background-color: #ffe7e8; color: #e33030;">
7+
</div>
38
<div class="form-footer">
49
<button (click)="onCancel.emit()" class="btn btn-link cancel" [disabled]="status?.saving">{{'Cancel' | translate}}</button>
510
<div class="loader inline small" *ngIf="status?.saving"></div>

webapp/src/ts/main.ts

+17
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,22 @@ window.startupTimes.firstCodeExecution = performance.now();
77

88
window.PouchDB = require('pouchdb-browser').default;
99
window.$ = window.jQuery = require('jquery');
10+
window._phdcChanges = {
11+
hierarchyDuplicatePrevention: {
12+
health_center: {
13+
...Levenshtein,
14+
props: [
15+
{form_prop_path: `/data/health_center/name`, db_doc_ref: 'name'},
16+
{form_prop_path: '/data/health_center/external_id', db_doc_ref: 'external_id'}
17+
],
18+
queryParams: {
19+
valuePaths: ['/data/health_center/is_user_flagged_duplicate', '/data/health_center/duplicate/action'],
20+
// eslint-disable-next-line eqeqeq
21+
query: (duplicate, action) => duplicate === 'yes' && action != null
22+
}
23+
}
24+
}
25+
};
1026

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

2137
import * as bootstrapper from '../js/bootstrapper';
38+
import { Levenshtein } from './polyfills';
2239

2340
// Moment additional locales
2441
require('../js/moment-locales/tl');

0 commit comments

Comments
 (0)