Projekt

Obecné

Profil

« Předchozí | Další » 

Revize c9f649fd

Přidáno uživatelem castic96 před téměř 5 roky(ů)

Re #8027: Checkbox pro spell checker FE
- vytvořen checkbox pro autocorrect

Zobrazit rozdíly:

fe/fulltextsearch/src/app/app.module.ts
35 35
import { FontAwesomeModule } from '@fortawesome/angular-fontawesome';
36 36
import { TranslateHttpLoader } from '@ngx-translate/http-loader';
37 37
import { TranslateLoader, TranslateModule } from '@ngx-translate/core';
38
import {MatCheckboxModule} from '@angular/material/checkbox';
38 39

  
39 40
export function HttpLoaderFactory(httpClient: HttpClient) {
40 41
  return new TranslateHttpLoader(httpClient, '../assets/i18n/', '-lang.json');
......
81 82
        useFactory: HttpLoaderFactory,
82 83
        deps: [HttpClient]
83 84
      }
84
    })
85
    }),
86
    MatCheckboxModule
85 87
  ],
86 88
  providers: [DataHolderService, DatePipe],
87 89
  bootstrap: [AppComponent]
fe/fulltextsearch/src/app/components/shared-components/search-box/search-box.component.css
56 56
.input-group-append .btn, .input-group-prepend .btn {
57 57
  z-index: 0 !important;
58 58
}
59

  
60
.input-group {
61
  margin-bottom: 8pt !important;
62
}
63

  
64
.mat-checkbox {
65
  padding: 6pt 6pt 1pt;
66
  background-color: white !important;
67
  color: var(--text-grey);
68
}
fe/fulltextsearch/src/app/components/shared-components/search-box/search-box.component.html
13 13
      <button class="btn btn-outline-secondary" type="button" (click)="onSubmit()">{{'app-search-box.search' | translate}}</button>
14 14
    </div>
15 15
  </div>
16
    <mat-checkbox color="warn" (change)="onToggle()">{{'app-search-box.spell-check' | translate}}</mat-checkbox>
16 17
</div>
fe/fulltextsearch/src/app/components/shared-components/search-box/search-box.component.ts
1
import {Component, OnDestroy, OnInit} from '@angular/core';
1
import { Component, OnDestroy, OnInit } from '@angular/core';
2 2
import { SearchRequest } from '../../../model/SearchRequest';
3 3
import { QueryService } from '../../../services/query/query.service';
4 4
import { Router } from '@angular/router';
5 5
import { DataHolderService } from '../../../services/data-holder/data-holder.service';
6
import {Subscription} from 'rxjs';
6
import { Subscription } from 'rxjs';
7 7

  
8 8
@Component({
9 9
  selector: 'app-search-box',
......
11 11
  styleUrls: ['./search-box.component.css']
12 12
})
13 13
export class SearchBoxComponent implements OnInit, OnDestroy {
14
  enableSpellCheck: boolean;
14 15
  expression: string;
15 16
  private queryServiceSubscription$: Subscription;
16 17

  
17 18
  constructor(private queryService: QueryService, private router: Router, private dataHolderService: DataHolderService) { }
18 19

  
19 20
  ngOnInit(): void {
21
    this.enableSpellCheck = false;
22
  }
23

  
24
  onToggle() {
25
    this.enableSpellCheck = !this.enableSpellCheck;
26
    console.log('kontrola spell check: ' + this.enableSpellCheck);
20 27
  }
21 28

  
22 29
  onSubmit(): void {
23 30
    if (!this.expression) { return; }
24 31

  
25
    const searchRequest: SearchRequest = new SearchRequest(this.expression, new Date());
26
    console.log('odeslano: ' + JSON.stringify(searchRequest));
32
    const searchRequest: SearchRequest = new SearchRequest(this.expression, new Date(), this.enableSpellCheck);
27 33

  
28 34
    this.queryServiceSubscription$ = this.queryService.searchPost(searchRequest).subscribe (data => {
29 35
      this.dataHolderService.setData(data);
......
34 40
  }
35 41

  
36 42
  ngOnDestroy(): void {
37
    console.log(this.queryServiceSubscription$);
38 43
    if (this.queryServiceSubscription$ !== undefined) {
39
      console.log('podminka');
40 44
      this.queryServiceSubscription$.unsubscribe();
41 45
    }
42 46
  }
fe/fulltextsearch/src/app/model/SearchRequest.ts
1 1
export class SearchRequest {
2 2
  public expression: string;
3 3
  public timestamp: Date;
4
  public enableSpellCheck: boolean;
4 5

  
5
  constructor(expression: string, timestamp: Date) {
6
  constructor(expression: string, timestamp: Date, enableSpellCheck: boolean) {
6 7
    this.expression = expression;
7 8
    this.timestamp = timestamp;
9
    this.enableSpellCheck = enableSpellCheck;
8 10
  }
9 11
}
fe/fulltextsearch/src/assets/i18n/cz-lang.json
12 12
  },
13 13
  "app-search-box": {
14 14
    "search": "Vyhledat",
15
    "placeholder": "Zadejte text k vyhledání..."
15
    "placeholder": "Zadejte text k vyhledání...",
16
    "spell-check": "Zapnout automatickou kontrolu"
16 17
  },
17 18
  "app-search": {
18 19
    "expression": "Hledaný výraz: ",
fe/fulltextsearch/src/assets/i18n/de-lang.json
12 12
  },
13 13
  "app-search-box": {
14 14
    "search": "Suchen",
15
    "placeholder": "Geben Sie den Text ein..."
15
    "placeholder": "Geben Sie den Text ein...",
16
    "spell-check": "Ermöglichen autocorrect"
16 17
  },
17 18
  "app-search": {
18 19
    "expression": "Suchtext: ",
fe/fulltextsearch/src/assets/i18n/en-lang.json
12 12
  },
13 13
  "app-search-box": {
14 14
    "search": "Search",
15
    "placeholder": "Enter text to search..."
15
    "placeholder": "Enter text to search...",
16
    "spell-check": "Enable autocorrect"
16 17
  },
17 18
  "app-search": {
18 19
    "expression": "Searching expression: ",

Také k dispozici: Unified diff