implement client list filtering
This commit is contained in:
parent
517a5ccbea
commit
1957277463
@ -15,6 +15,7 @@ limitations under the License.
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import {isWebPlatform, Platform} from "./Platform.js";
|
import {isWebPlatform, Platform} from "./Platform.js";
|
||||||
|
import {Maturity} from "./types.js";
|
||||||
import {ClientViewModel} from "./ClientViewModel.js";
|
import {ClientViewModel} from "./ClientViewModel.js";
|
||||||
import {ViewModel} from "../utils/ViewModel.js";
|
import {ViewModel} from "../utils/ViewModel.js";
|
||||||
|
|
||||||
@ -22,17 +23,35 @@ export class ClientListViewModel extends ViewModel {
|
|||||||
constructor(options) {
|
constructor(options) {
|
||||||
super(options);
|
super(options);
|
||||||
const {clients, client, link} = options;
|
const {clients, client, link} = options;
|
||||||
this.clientList = clients.map(client => new ClientViewModel(this.childOptions({
|
this._clients = clients;
|
||||||
client,
|
this._link = link;
|
||||||
link,
|
this.clientList = null;
|
||||||
pickClient: client => this._pickClient(client)
|
this._showExperimental = true;
|
||||||
})));
|
this._showUnsupportedPlatform = true;
|
||||||
|
this._filterClients();
|
||||||
this.clientViewModel = null;
|
this.clientViewModel = null;
|
||||||
if (client) {
|
if (client) {
|
||||||
this._pickClient(client);
|
this._pickClient(client);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_filterClients() {
|
||||||
|
this.clientList = this._clients.filter(client => {
|
||||||
|
if (!this._showExperimental && !this.platforms.map(p => client.getMaturity(p)).includes(Maturity.Stable)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!this._showUnsupportedPlatform && !client.platforms.some(p => this.platforms.includes(p))) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}).map(client => new ClientViewModel(this.childOptions({
|
||||||
|
client,
|
||||||
|
link: this._link,
|
||||||
|
pickClient: client => this._pickClient(client)
|
||||||
|
})));
|
||||||
|
this.emitChange();
|
||||||
|
}
|
||||||
|
|
||||||
_pickClient(client) {
|
_pickClient(client) {
|
||||||
this.clientViewModel = this.clientList.find(vm => vm.clientId === client.id);
|
this.clientViewModel = this.clientList.find(vm => vm.clientId === client.id);
|
||||||
this.emitChange();
|
this.emitChange();
|
||||||
|
Loading…
Reference in New Issue
Block a user