fixed select-viewer
@@ -4,21 +4,31 @@ import { attach } from "../../../utils.js";
const serviceDependencies = ["$scope", "$element"];
function genComponentConf() {
let template = `
- <div class="tv__header">
- <svg class="tv__header__icon" ng-if="self.detail.icon">
+ <div class="selectv__header">
+ <svg class="selectv__header__icon" ng-if="self.detail.icon">
<use xlink:href={{self.detail.icon}} href={{self.detail.icon}}></use>
</svg>
- <span class="tv__header__label" ng-if="self.detail.label">{{self.detail.label}}</span>
+ <span class="selectv__header__label" ng-if="self.detail.label">{{self.detail.label}}</span>
</div>
- <div class="tv__content">
- <div class="tv__content__tag" ng-repeat="tag in self.content.toJS()">{{tag}}</div>
+ <div class="selectv__content">
+ <label ng-repeat="option in self.detail.options"
+ class="selectv__input__inner">
+ <input
+ class="selectv__input__inner__select"
+ type="{{ self.getSelectType() }}"
+ name="{{ self.getInputName() }}"
+ value="{{option.value}}"
+ disabled="true"
+ ng-checked="self.isChecked(option)"/>
+ {{ option.label }}
+ </label>
</div>
`;
class Controller {
constructor() {
attach(this, serviceDependencies, arguments);
- window.tv4dbg = this;
+ window.selectv4dbg = this;
this.$scope.$watch("self.content", (newContent, prevContent) =>
this.updatedContent(newContent, prevContent)
@@ -28,6 +38,14 @@ function genComponentConf() {
);
}
+ getSelectType() {
+ return this.detail && this.detail.multiSelect ? "checkbox" : "radio";
+ }
+
+ isChecked(option) {
+ return this.content && !!this.content.find(elem => elem === option.value);
+ }
+
updatedDetails(newDetails, prevDetails) {
if (newDetails && newDetails != prevDetails) {
this.details = newDetails;
@@ -38,6 +56,12 @@ function genComponentConf() {
this.content = newContent;
}
}
+
+ getInputName() {
+ /*TODO: Implement a sort of hashcode to prepend to the returned name to add the
+ possibility of using the same identifier in is and seeks for these viewers*/
+ return this.detail.identifier;
+ }
}
Controller.$inject = serviceDependencies;
