Skip to content

Commit 123ea2d

Browse files
committed
adding model search text box - not wired up yet
1 parent 2133437 commit 123ea2d

File tree

4 files changed

+65
-1
lines changed

4 files changed

+65
-1
lines changed

electron/app/locales/en/webui.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1029,6 +1029,7 @@
10291029
"aux-image-pusher-create-failed-title":"Push Image Failed",
10301030
"aux-image-pusher-create-failed-error-message":"Unable to push image {{imageTag}}: {{error}}.",
10311031

1032+
"model-page-design-view-search-label": "Search Model",
10321033
"model-page-button-validateModel": "Validate Model",
10331034
"model-page-hints-validateModel": "Validate Model Files",
10341035
"model-page-button-prepareModel": "Prepare Model",

webui/src/js/viewModels/model-design-view.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ function(accUtils, i18n, ko, project, urlCatalog, viewHelper, wktLogger, jsYaml,
1616
this.dataProvider = {};
1717
this.disableStartButton = ko.observable(false);
1818
this.wrcBackendTriggerChange = false;
19+
this.searchModelElement = undefined;
1920

2021
this.connected = () => {
2122
accUtils.announce('Model design view loaded.', 'assertive');
@@ -50,6 +51,15 @@ function(accUtils, i18n, ko, project, urlCatalog, viewHelper, wktLogger, jsYaml,
5051
});
5152
}
5253
}
54+
55+
const element = document.getElementById('modelDesignSearchInput');
56+
if (element) {
57+
wktLogger.debug('Found modelDesignSearchInput');
58+
this.searchModelElement = element;
59+
this.searchModelElement.addEventListener('searchModel', this.handleSearchModelEvent);
60+
} else {
61+
wktLogger.error('Failed to find modelDesignSearchInput');
62+
}
5363
};
5464

5565
this.disconnected = function() {
@@ -61,6 +71,10 @@ function(accUtils, i18n, ko, project, urlCatalog, viewHelper, wktLogger, jsYaml,
6171
wktLogger.debug('disconnected() dataProvider = %s', JSON.stringify(this.dataProvider));
6272
this.designer.deactivateProvider(this.dataProvider);
6373
}
74+
75+
if (this.searchModelElement) {
76+
this.searchModelElement.removeEventListener('searchModel', this.handleSearchModelEvent);
77+
}
6478
};
6579

6680
this.labelMapper = (labelId, payload) => {
@@ -238,6 +252,15 @@ function(accUtils, i18n, ko, project, urlCatalog, viewHelper, wktLogger, jsYaml,
238252
document.querySelector('oj-button#start-wrc-button span').style.cursor = 'wait';
239253
return window.api.ipc.invoke('wrc-set-home-and-start', rcHome);
240254
};
255+
256+
this.handleSearchModelEvent = (event) => {
257+
const searchModelText = event.detail.value;
258+
wktLogger.debug('received searchModel event: %s', searchModelText);
259+
260+
// Once the WRC change is available, call the method to pass the search text and return.
261+
//
262+
// this.designer.simpleSearch(searchModelText);
263+
};
241264
}
242265

243266
/*

webui/src/js/viewModels/model-page-impl.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ define([],
3434
};
3535

3636
this.selectedItem = ko.observable('model-code-view');
37+
this.inDesignView = ko.computed(() => {
38+
return this.selectedItem() === 'model-design-view';
39+
});
40+
3741
this.dataProvider = new ArrayDataProvider(navData.slice(1), {keyAttributes: 'path'});
3842

3943
let router = args.parentRouter.createChildRouter(navData, {history: 'skip'});
@@ -44,6 +48,25 @@ define([],
4448
this.selectedItem.subscribe((newValue) => {
4549
router.go({path: newValue});
4650
});
51+
52+
this.disableSearch = ko.observable(false);
53+
this.enterKeyPressedInSearchInput = (event) => {
54+
if (event.detail.originalEvent.keyCode === 13) {
55+
this.searchModel();
56+
}
57+
};
58+
59+
this.searchModel = () => {
60+
const searchModelElement = document.getElementById('modelDesignSearchInput');
61+
if (searchModelElement && searchModelElement.value) {
62+
const payload = {
63+
detail: {
64+
value: searchModelElement.value
65+
}
66+
};
67+
searchModelElement.dispatchEvent(new CustomEvent('searchModel', payload));
68+
}
69+
};
4770
}
4871

4972
/*

webui/src/js/views/model-page.html

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Copyright (c) 2021, 2022, Oracle and/or its affiliates.
33
Licensed under The Universal Permissive License (UPL), Version 1.0 as shown at https://oss.oracle.com/licenses/upl/
44
-->
5-
<div class="wkt-content-layout">
5+
<div id="modelPage" class="wkt-content-layout">
66
<div class="wkt-content-top-bar">
77
<oj-tab-bar class="oj-sm-condense oj-tabbar wkt-tab-bar"
88
selection="{{selectedItem}}"
@@ -15,6 +15,23 @@
1515
</li>
1616
</template>
1717
</oj-tab-bar>
18+
<oj-bind-if test="[[inDesignView() === true]]">
19+
<oj-input-text id="modelDesignSearchInput"
20+
disabled="[[disableSearch]]"
21+
on-value-changed="[[enterKeyPressedInSearchInput]]"
22+
label-hint="[[labelMapper('design-view-search-label')]]">
23+
<oj-button
24+
id="searchModelButton"
25+
disabled="[[disableSearch]]"
26+
slot="end"
27+
display="icons"
28+
chroming="borderless"
29+
on-oj-action="[[searchModel]]">
30+
<span slot="endIcon" class="oj-ux-ico-search" role="img"></span>
31+
</oj-button>
32+
</oj-input-text>
33+
</oj-bind-if>
34+
1835
<oj-button id="validateModelButton"
1936
disabled="[[disableValidate]]"
2037
chroming="callToAction"

0 commit comments

Comments
 (0)