Project

General

Profile

« Previous | Next » 

Revision 59180

[use-UoaAdminToolsLibrary | Library]: Merge trunk into branch.

View differences:

quick-selections.component.ts
9 9
@Component({
10 10
  selector: 'quick-selections',
11 11
  template: `
12
    <form *ngIf="resultTypes || quickFilter" [formGroup]="control" class="uk-text-small uk-margin-small-bottom">
13
      <div  *ngIf="quickFilter" class="uk-margin-small-top uk-margin-small-left">
12
    <form *ngIf="!vertical && (resultTypes || quickFilter)" [formGroup]="control" 
13
          [class]="(isDisabled ? 'uk-disabled' : '') + ' uk-text-small uk-margin-small-bottom uk-grid uk-inline uk-flex uk-margin-small-left'">
14
      <div  *ngIf="quickFilter" class="uk-margin-small-top uk-padding-remove-left uk-margin-right ">
14 15
        <span class="uk-text-bold">{{quickFilter.value}}</span>
15 16
        <mat-slide-toggle
16 17
                          class="uk-margin-small-left" formControlName="QFselected" (change)="quickFilterChanged()">
17 18
        </mat-slide-toggle>
18 19
      </div>
19
      <div *ngIf="resultTypes && showEntities" class="uk-margin-small-top uk-margin-small-left">
20
      <div *ngIf="resultTypes && showEntities" class="uk-margin-small-top uk-padding-remove-left">
20 21
        <span class="uk-text-muted">Include: </span>
21
      <span>
22
        <span *ngIf="showPublications" class="uk-margin-small-left"> <input type="checkbox" id="publ" name="Publications" formControlName="publication" (change)="changed()"> Publications </span>
23
        <span *ngIf="showDatasets" class="uk-margin-small-left"> <input type="checkbox" formControlName="dataset" (change)="changed()"> Research data </span>
24
        <span *ngIf="showSoftware" class="uk-margin-small-left"> <input type="checkbox" formControlName="software" (change)="changed()"> Software </span>
25
        <span *ngIf="showOrp" class="uk-margin-small-left"> <input type="checkbox" formControlName="other" (change)="changed()"> Other research products </span>
26
      </span>
22
        <span>
23
          <span *ngIf="showPublications" class="uk-margin-small-left"> <input type="checkbox" id="publ" name="Publications" formControlName="publication" (change)="changed()"> Publications </span>
24
          <span *ngIf="showDatasets" class="uk-margin-small-left"> <input type="checkbox" formControlName="dataset" (change)="changed()"> Research data </span>
25
          <span *ngIf="showSoftware" class="uk-margin-small-left"> <input type="checkbox" formControlName="software" (change)="changed()"> Software </span>
26
          <span *ngIf="showOrp" class="uk-margin-small-left"> <input type="checkbox" formControlName="other" (change)="changed()"> Other research products </span>
27
        </span>
27 28
      </div>
28 29
    </form>
30
    <form *ngIf="vertical && (resultTypes || quickFilter)" [formGroup]="control" 
31
          [class]="(isDisabled ? 'uk-disabled' : '') + ' uk-margin-small-bottom uk-list uk-list-divider'">
32
    <!--  <li   *ngIf="quickFilter" class="uk-margin-small-bottom ">
33
        <div class="uk-margin-small-top uk-padding-remove-left uk-margin-right ">
34
          <h5 class="">{{quickFilter.value}}</h5>
35
          <mat-slide-toggle
36
            class="uk-margin-small-left" formControlName="QFselected" (change)="quickFilterChanged()">
37
          </mat-slide-toggle>
38
        </div>
39
      </li>-->
40
<!--      {{showEntities}} - {{showPublications}} - {{showDatasets}} - {{showSoftware}} &#45;&#45; {{showOrp}}-->
41
      <li *ngIf="resultTypes && showEntities" class="uk-margin-small-bottom ng-star-inserted">
42
        <div class="uk-margin-small-top uk-margin-bottom uk-grid uk-flex uk-flex-bottom">
43
          <h5 class="uk-margin-bottom-remove" title="Community">Research Type ({{(this.showPublications + this.showDatasets + this.showSoftware + this.showOrp)}})</h5>
44
          <a *ngIf="selectedTypesNum>0" (click)="clearTypes()" class="portal-link">
45
            Clear
46
          </a>
47
        </div>
48
        <div>
49
          <div>
50
            <div *ngIf="showPublications" class="uk-animation-fade filterItem searchFilterItem uk-text-small ng-star-inserted">
51
              <div title="Publications">
52
                <label class="ng-star-inserted"><input class="uk-checkbox" type="checkbox" id="publ" name="Publications" formControlName="publication" (change)="changed()"> Publications</label>
53
              </div>
54
            </div>
55
            <div *ngIf="showDatasets"  class="uk-animation-fade filterItem searchFilterItem uk-text-small ng-star-inserted">
56
              <div title="Research data">
57
                <label class="ng-star-inserted"><input class="uk-checkbox" type="checkbox" formControlName="dataset" (change)="changed()"> Research data </label>
58
              </div>
59
            </div>
60
            <div *ngIf="showSoftware" class="uk-animation-fade filterItem searchFilterItem uk-text-small ng-star-inserted">
61
              <div title="Software">
62
                <label class="ng-star-inserted"> <input class="uk-checkbox" type="checkbox" formControlName="software" (change)="changed()"> Software</label>
63
              </div>
64
            </div>
65
            <div *ngIf="showOrp" class="uk-animation-fade filterItem searchFilterItem uk-text-small ng-star-inserted">
66
              <div title=" Other research products">
67
                <label class="ng-star-inserted"><input class="uk-checkbox" type="checkbox" formControlName="other" (change)="changed()"> Other research products</label>
68
              </div>
69
            </div>
70
          </div>
71
        </div>
72
      </li>
73
    </form>
29 74
  `
30 75
})
31 76

  
......
38 83
  control: FormGroup;
39 84
  initialized = false;
40 85
  @Input() properties: EnvProperties;
86
  @Input() vertical: boolean=false;
41 87
  showPublications:boolean= false;
42 88
  showDatasets:boolean= false;
43 89
  showSoftware: boolean = false;
44 90
  showOrp: boolean = false;
45 91
  showEntities = false;
46
  resultTypesObs: Subscription ;
92
  selectedTypesNum = 0;
93
  @Input() delayTime = 0;
47 94
  private clicks = new Subject();
95

  
96
  subs: Subscription[] = [];
97

  
48 98
  constructor(private _fb: FormBuilder, private config: ConfigurationService) {
49 99

  
50 100
    this.control = this._fb.group({
......
72 122
    this.resultTypes.dataset = value.dataset;
73 123
    this.resultTypes.software = value.software;
74 124
    this.resultTypes.other = value.other;
75
    if (this.resultTypes && !this.resultTypes.publication && !this.resultTypes.dataset && !this.resultTypes.software && !this.resultTypes.other) {
125
    if (this.resultTypes && !this.resultTypes.publication && !this.resultTypes.dataset && !this.resultTypes.software && !this.resultTypes.other && !this.vertical) {
76 126
      this.resultTypes.publication = true;
77 127
      this.resultTypes.dataset = true;
78 128
      this.resultTypes.software = true;
......
110 160
      this.setFormValues();
111 161
    }
112 162
    if(this.properties) {
113
      this.config.getCommunityInformation(this.properties, this.properties.adminToolsCommunity).subscribe(data => {
114
        var showEntity = {};
115
        for (var i = 0; i < data['entities'].length; i++) {
116
          showEntity["" + data['entities'][i]["pid"] + ""] = data['entities'][i]["isEnabled"];
117
        }
118
        this.showPublications = showEntity["publication"];
119
        this.showDatasets = showEntity["dataset"];
120
        this.showSoftware = showEntity["software"];
121
        this.showOrp = showEntity["orp"];
122
        this.showEntities = this.showPublications || this.showDatasets || this.showSoftware || this.showOrp;
123
      });
163
      if(this.properties.adminToolsCommunity !== "monitor") {
164
        //this.subs.push(this.config.getCommunityInformation(this.properties, this.properties.adminToolsCommunity).subscribe(data => {
165
        this.subs.push(this.config.communityInformationState.subscribe(data => {
166
          if(data) {
167
            var showEntity = {};
168
            for (var i = 0; i < data['entities'].length; i++) {
169
              showEntity["" + data['entities'][i]["pid"] + ""] = data['entities'][i]["isEnabled"];
170
            }
171
            this.showPublications = showEntity["publication"];
172
            this.showDatasets = showEntity["dataset"];
173
            this.showSoftware = showEntity["software"];
174
            this.showOrp = showEntity["orp"];
175
            this.showEntities = this.showPublications || this.showDatasets || this.showSoftware || this.showOrp;
176
          }
177
        }, error => {
178
          this.showPublications = true;
179
          this.showDatasets = true;
180
          this.showSoftware = true;
181
          this.showOrp = true;
182
          this.showEntities = true;
183
        }));
184
      } else {
185
        this.showPublications = true;
186
        this.showDatasets = true;
187
        this.showSoftware = true;
188
        this.showOrp = true;
189
        this.showEntities = true;
190
      }
124 191
    }
125
    this.resultTypesObs  = this.clicks.pipe(
126
      debounceTime(1000)
127
    ).subscribe(e =>{this.actuallyChanged()} );
192
    this.subs.push(this.clicks.pipe(
193
      debounceTime(this.delayTime)
194
    ).subscribe(e =>{this.actuallyChanged()} ));
128 195

  
129 196
  }
130 197

  
198
  public ngOnDestroy() {
199
    for (let sub of this.subs) {
200
      sub.unsubscribe();
201
    }
202
  }
203

  
131 204
  ngOnChanges(changes: SimpleChanges): void {
132 205
    if (changes.isDisabled) {
133 206
      if (changes.isDisabled.currentValue == true) {
......
144 217
      }
145 218

  
146 219
    }
220
    if (changes.resultTypes) {
221
      this.setFormValues();
222
    }
147 223
  }
148 224

  
149 225
  setFormValues() {
......
154 230
      other: (this.resultTypes && this.resultTypes.other)?this.resultTypes.other:null,
155 231
      QFselected: this.QFselected
156 232
    });
233
    this.selectedTypesNum = (this.resultTypes && this.resultTypes.publication)?this.resultTypes.publication:0 + (this.resultTypes && this.resultTypes.dataset)?this.resultTypes.dataset:0+ (this.resultTypes && this.resultTypes.software)?this.resultTypes.software:0 + (this.resultTypes && this.resultTypes.other)?this.resultTypes.other:null;
157 234
  }
158 235

  
236
  clearTypes(){
237
    this.resultTypes.publication = false;
238
    this.resultTypes.dataset = false;
239
    this.resultTypes.software = false;
240
    this.resultTypes.other = false;
241
    this.setFormValues();
242
    this.changed()
243
  }
159 244

  
160 245
}

Also available in: Unified diff