Skip to content

Commit df19da2

Browse files
committed
[UXP-184] Fix after merge with 7.6.2
1 parent 31e78f8 commit df19da2

3 files changed

Lines changed: 31 additions & 26 deletions

File tree

src/app/shared/form/builder/ds-dynamic-form-ui/models/scrollable-dropdown/dynamic-scrollable-dropdown.component.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,12 @@
6161
[attr.id]="listEntry.display == (currentValue|async) ? ('combobox_' + id + '_selected') : null">
6262
{{inputFormatter(listEntry)}}
6363
</button>
64-
<div class="d-flex align-items-center pl-4 pr-3 py-2" id="otherOption"
64+
<div class="d-flex align-items-center pl-4 pr-3 py-2" data-test="otherOption"
6565
*ngIf="model.openType && (pageInfo.currentPage >= pageInfo.totalPages)">
6666
<label class="m-0">{{'form.other-option' | translate}}</label>
67-
<input id="otherOptionInput" type="text" class="form-control form-control-sm mx-2" [(ngModel)]="otherListEntry" (keyup.enter)="addListItem(sdRef)" />
68-
<button id="otherOptionBtn" class="btn btn-primary btn-sm" type="button"
69-
(click)="addListItem(sdRef)" [disabled]="addButoonDisabled">
67+
<input data-test="otherOptionInput" type="text" class="form-control form-control-sm mx-2" [(ngModel)]="otherListEntry" (keyup.enter)="addListItem(sdRef)" />
68+
<button data-test="otherOptionBtn" class="btn btn-primary btn-sm" type="button"
69+
(click)="addListItem(sdRef)" [disabled]="addButtonDisabled">
7070
{{'form.other-option.add-button' | translate}}
7171
</button>
7272
</div>

src/app/shared/form/builder/ds-dynamic-form-ui/models/scrollable-dropdown/dynamic-scrollable-dropdown.component.spec.ts

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -151,31 +151,33 @@ describe('Dynamic Dynamic Scrollable Dropdown component', () => {
151151
});
152152

153153
it('should display other dropdown menu option', () => {
154-
scrollableDropdownComp.model.openType = true;
155-
scrollableDropdownComp.pageInfo.currentPage = 2;
156-
scrollableDropdownComp.pageInfo.totalPages = 1;
157154
const de = scrollableDropdownFixture.debugElement.query(By.css('input.form-control'));
158155
const btnEl = de.nativeElement;
159-
160156
btnEl.click();
157+
scrollableDropdownFixture.detectChanges();
161158

159+
scrollableDropdownComp.model.openType = true;
160+
scrollableDropdownComp.pageInfo.currentPage = 2;
161+
scrollableDropdownComp.pageInfo.totalPages = 1;
162162
scrollableDropdownFixture.detectChanges();
163-
const deMenu = scrollableDropdownFixture.debugElement.query(By.css('#otherOption'));
163+
164+
const deMenu = scrollableDropdownFixture.debugElement.query(By.css('[data-test="otherOption"]'));
164165

165166
expect(deMenu).toBeTruthy();
166167
});
167168

168169
it('should not display other dropdown menu option', () => {
169-
scrollableDropdownComp.model.openType = true;
170-
scrollableDropdownComp.pageInfo.currentPage = 2;
171-
scrollableDropdownComp.pageInfo.totalPages = 3;
172170
const de = scrollableDropdownFixture.debugElement.query(By.css('input.form-control'));
173171
const btnEl = de.nativeElement;
174-
175172
btnEl.click();
173+
scrollableDropdownFixture.detectChanges();
176174

175+
scrollableDropdownComp.model.openType = true;
176+
scrollableDropdownComp.pageInfo.currentPage = 2;
177+
scrollableDropdownComp.pageInfo.totalPages = 3;
177178
scrollableDropdownFixture.detectChanges();
178-
const deMenu = scrollableDropdownFixture.debugElement.query(By.css('#otherOption'));
179+
180+
const deMenu = scrollableDropdownFixture.debugElement.query(By.css('[data-test="otherOption"]'));
179181

180182
expect(deMenu).toBeFalsy();
181183
});
@@ -215,17 +217,20 @@ describe('Dynamic Dynamic Scrollable Dropdown component', () => {
215217
it('should add other dropdown option value', () => {
216218
const selectedValue = Object.assign(new VocabularyEntry(), { authority: 3, display: 'three', value: 'three' });
217219
spyOn((scrollableDropdownComp as any), 'addListItem');
218-
scrollableDropdownComp.model.openType = true;
219-
scrollableDropdownComp.pageInfo.currentPage = 2;
220-
scrollableDropdownComp.pageInfo.totalPages = 1;
220+
221221
const de = scrollableDropdownFixture.debugElement.query(By.css('input.form-control'));
222222
let btnEl = de.nativeElement;
223223

224224
btnEl.click();
225+
scrollableDropdownFixture.detectChanges();
225226

227+
scrollableDropdownComp.model.openType = true;
228+
scrollableDropdownComp.pageInfo.currentPage = 2;
229+
scrollableDropdownComp.pageInfo.totalPages = 1;
226230
scrollableDropdownFixture.detectChanges();
231+
227232
scrollableDropdownComp.otherListEntry = selectedValue.value;
228-
btnEl = scrollableDropdownFixture.debugElement.nativeElement.querySelector('#otherOptionBtn');
233+
btnEl = scrollableDropdownFixture.debugElement.nativeElement.querySelector('[data-test="otherOptionBtn"]');
229234

230235
btnEl.click();
231236
scrollableDropdownFixture.detectChanges();

src/app/shared/form/builder/ds-dynamic-form-ui/models/scrollable-dropdown/dynamic-scrollable-dropdown.component.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ export class DsDynamicScrollableDropdownComponent extends DsDynamicVocabularyCom
6161
public selectedIndex = 0;
6262
public acceptableKeys = ['Space', 'NumpadMultiply', 'NumpadAdd', 'NumpadSubtract', 'NumpadDecimal', 'Semicolon', 'Equal', 'Comma', 'Minus', 'Period', 'Quote', 'Backquote'];
6363
public otherListEntry = '';
64-
public addButoonDisabled = false;
64+
public addButtonDisabled = false;
6565

6666

6767
/**
@@ -75,7 +75,7 @@ export class DsDynamicScrollableDropdownComponent extends DsDynamicVocabularyCom
7575
filterTextChanged: Subject<string> = new Subject<string>();
7676

7777
/**
78-
* The subscribtion to be utilized on destroy to remove filterTextChange subscription
78+
* The subscription to be utilized on destroy to remove filterTextChange subscription
7979
*/
8080
subSearch: Subscription;
8181

@@ -201,7 +201,7 @@ export class DsDynamicScrollableDropdownComponent extends DsDynamicVocabularyCom
201201
this.inputText += keyName;
202202
// When a new key is added, we need to reset the page info
203203
this.updatePageInfo(this.model.maxOptions, 1);
204-
this.retrieveEntries(null, false);
204+
this.retrieveEntries(this.inputText, false);
205205
}
206206

207207
removeKeyFromInput() {
@@ -210,7 +210,7 @@ export class DsDynamicScrollableDropdownComponent extends DsDynamicVocabularyCom
210210
if (this.inputText === '') {
211211
this.inputText = null;
212212
}
213-
this.retrieveEntries(null, false);
213+
this.retrieveEntries(this.inputText, false);
214214
}
215215
}
216216

@@ -337,7 +337,7 @@ export class DsDynamicScrollableDropdownComponent extends DsDynamicVocabularyCom
337337
*/
338338
addListItem(sdRef: NgbDropdown) {
339339
let entryCount = 0;
340-
this.addButoonDisabled = true;
340+
this.addButtonDisabled = true;
341341
if (this.otherListEntry.toString() !== '') {
342342
if (this.optionsList.length > 0) {
343343
this.optionsList.forEach(element => {
@@ -353,12 +353,12 @@ export class DsDynamicScrollableDropdownComponent extends DsDynamicVocabularyCom
353353
this.optionsList.push(object);
354354
this.onSelect(object);
355355
sdRef.close();
356-
this.addButoonDisabled = false;
356+
this.addButtonDisabled = false;
357357
} else {
358-
this.addButoonDisabled = false;
358+
this.addButtonDisabled = false;
359359
}
360360
} else {
361-
this.addButoonDisabled = false;
361+
this.addButtonDisabled = false;
362362
}
363363
}
364364

0 commit comments

Comments
 (0)