@thecodeblogs/blog 0.15.3 → 0.15.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -34,7 +34,7 @@ import { FileUploader, FileUploadModule } from 'ng2-file-upload';
34
34
  import * as i1$3 from '@fortawesome/angular-fontawesome';
35
35
  import { FontAwesomeModule } from '@fortawesome/angular-fontawesome';
36
36
  import * as i6$1 from '@angular/forms';
37
- import { UntypedFormControl, FormsModule, ReactiveFormsModule } from '@angular/forms';
37
+ import { UntypedFormControl, FormControl, FormsModule, ReactiveFormsModule } from '@angular/forms';
38
38
  import * as i8 from '@angular/material/card';
39
39
  import { MatCardModule } from '@angular/material/card';
40
40
  import * as i9 from '@angular/material/input';
@@ -59,7 +59,8 @@ import * as i1$4 from '@angular/router';
59
59
  import { NavigationEnd, RouterModule } from '@angular/router';
60
60
  import * as i3 from '@angular/cdk/drag-drop';
61
61
  import { DragDropModule } from '@angular/cdk/drag-drop';
62
- import * as i5$1 from '@angular/material/list';
62
+ import { trigger, state, style, transition, animate } from '@angular/animations';
63
+ import * as i8$1 from '@angular/material/list';
63
64
  import { MatListModule } from '@angular/material/list';
64
65
  import * as i3$1 from '@angular/material/sidenav';
65
66
  import { MatSidenavModule } from '@angular/material/sidenav';
@@ -314,6 +315,9 @@ class EntryService extends DjangoRestFrameworkEndpointService {
314
315
  get() {
315
316
  return this.http.get(this.endpoint).pipe(map(this.handleListResponse.bind(this)));
316
317
  }
318
+ search(searchTerm) {
319
+ return this.http.get(this.endpoint + "?search=" + searchTerm).pipe(map(this.handleListResponse.bind(this)));
320
+ }
317
321
  getUnpublishedEntries() {
318
322
  const params = new HttpParams().set('published', JSON.stringify(false)).set('defunct', JSON.stringify(false));
319
323
  return this.http.get(this.adminEndpoint, { params });
@@ -1374,14 +1378,22 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImpor
1374
1378
  }], ctorParameters: function () { return [{ type: EntryService }]; } });
1375
1379
 
1376
1380
  class SideNavigationComponent {
1377
- constructor(entryService, router, identityService) {
1381
+ constructor(entryService, router, identityService, renderer) {
1378
1382
  this.entryService = entryService;
1379
1383
  this.router = router;
1380
1384
  this.identityService = identityService;
1385
+ this.renderer = renderer;
1386
+ this.state = 'out';
1381
1387
  this.entries = [];
1382
1388
  this.entriesByMonthAndYear = [];
1389
+ this.searchTerm = "";
1390
+ this.doSearch = new EventEmitter();
1391
+ this.searchControl = new FormControl('');
1383
1392
  }
1384
1393
  ngOnInit() {
1394
+ this.doSearch.pipe(debounceTime(500)).subscribe((result) => {
1395
+ this.searchEntries(result);
1396
+ });
1385
1397
  this.identityService.getMe().subscribe((identity) => {
1386
1398
  this.identity = identity;
1387
1399
  }, (err) => {
@@ -1403,30 +1415,41 @@ class SideNavigationComponent {
1403
1415
  });
1404
1416
  }
1405
1417
  organizeEntries() {
1406
- for (const entryWrapper of this.entries) {
1407
- const entry = entryWrapper.entry;
1408
- const create_date = new Date(entry.create_date);
1409
- const month = create_date.getMonth();
1410
- const year = create_date.getFullYear();
1411
- const key = month + '/' + year;
1412
- const sort_index = (year * 100) + month;
1413
- const containers = filter(this.entriesByMonthAndYear, (entryContainer) => entryContainer.month_year === key);
1414
- if (containers.length > 0) {
1415
- const container = containers[0];
1416
- const entriesWithId = filter(container.entries, (e) => e.id === entryWrapper.entry.id);
1417
- if (entriesWithId.length === 0) {
1418
- container.entries.push(entry);
1418
+ this.state = 'out';
1419
+ let organizeEntriesFn = () => {
1420
+ this.entriesByMonthAndYear = [];
1421
+ let newEntries = JSON.parse(JSON.stringify(this.entriesByMonthAndYear));
1422
+ for (const entryWrapper of this.entries) {
1423
+ const entry = entryWrapper.entry;
1424
+ const create_date = new Date(entry.create_date);
1425
+ const month = create_date.getMonth();
1426
+ const year = create_date.getFullYear();
1427
+ const key = month + '/' + year;
1428
+ const sort_index = (year * 100) + month;
1429
+ const containers = filter(newEntries, (entryContainer) => entryContainer.month_year === key);
1430
+ if (containers.length > 0) {
1431
+ const container = containers[0];
1432
+ const entriesWithId = filter(container.entries, (e) => e.id === entryWrapper.entry.id);
1433
+ if (entriesWithId.length === 0) {
1434
+ container.entries.push(entry);
1435
+ }
1436
+ }
1437
+ else {
1438
+ const newContainer = { month_year: key, month_year_number: sort_index, entries: [entry] };
1439
+ newEntries.push(newContainer);
1419
1440
  }
1420
1441
  }
1421
- else {
1422
- const newContainer = { month_year: key, month_year_number: sort_index, entries: [entry] };
1423
- this.entriesByMonthAndYear.push(newContainer);
1424
- }
1425
- }
1426
- this.entriesByMonthAndYear.sort((entry_a, entry_b) => {
1427
- return entry_a.month_year_number - entry_b.month_year_number;
1428
- });
1429
- this.entriesByMonthAndYear.reverse();
1442
+ newEntries.sort((entry_a, entry_b) => {
1443
+ return entry_a.month_year_number - entry_b.month_year_number;
1444
+ });
1445
+ newEntries.reverse();
1446
+ let setEntriesFn = () => {
1447
+ this.entriesByMonthAndYear = newEntries;
1448
+ this.state = 'in';
1449
+ };
1450
+ setTimeout(setEntriesFn.bind(this), 400);
1451
+ };
1452
+ setTimeout(organizeEntriesFn.bind(this), 400);
1430
1453
  }
1431
1454
  getEntries() {
1432
1455
  this.entryService.get().subscribe((response) => {
@@ -1441,6 +1464,24 @@ class SideNavigationComponent {
1441
1464
  }
1442
1465
  });
1443
1466
  }
1467
+ searchEntries(searchTerm) {
1468
+ if (searchTerm !== "") {
1469
+ this.entryService.search(searchTerm).subscribe((response) => {
1470
+ this.entries = map$1(response.results, (result) => {
1471
+ return { id: result.id, entry: new Entry(result) };
1472
+ });
1473
+ if (response.next) {
1474
+ this.getEntriesWithUrl(response.next);
1475
+ }
1476
+ else {
1477
+ this.organizeEntries();
1478
+ }
1479
+ });
1480
+ }
1481
+ else {
1482
+ this.getEntries();
1483
+ }
1484
+ }
1444
1485
  render() {
1445
1486
  }
1446
1487
  routeTo(entry) {
@@ -1506,13 +1547,41 @@ class SideNavigationComponent {
1506
1547
  this.sourceSub = null;
1507
1548
  }
1508
1549
  }
1550
+ onSearchChange(searchValue) {
1551
+ this.doSearch.emit(searchValue);
1552
+ }
1509
1553
  }
1510
- SideNavigationComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: SideNavigationComponent, deps: [{ token: EntryService }, { token: i1$4.Router }, { token: IdentityService }], target: i0.ɵɵFactoryTarget.Component });
1511
- SideNavigationComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.1.4", type: SideNavigationComponent, selector: "app-side-navigation", ngImport: i0, template: "<div class=\"sidenav no-scrollbar\">\n <mat-nav-list *ngFor=\"let container of entriesByMonthAndYear\">\n <h3>{{getMonthAndYearFromKey(container.month_year)}}</h3>\n <a mat-list-item *ngFor=\"let entry of container.entries\" href=\"javascript:void(0)\" (click)=\"routeTo(entry)\">{{entry.title}}</a>\n </mat-nav-list>\n\n <ng-container *ngIf=\"identity?.id === 1\">\n <h2>Misc</h2>\n\n <mat-nav-list>\n <a mat-list-item href=\"javascript:void(0);\" (click)=\"routeTo(null)\">Create</a>\n </mat-nav-list>\n </ng-container>\n <h3 *ngIf=\"identity\">Logged in as {{identity?.email}}</h3>\n</div>\n\n", styles: [".sidenav{max-height:calc(100vh - 100px)}@media screen and (max-height: 560px){.sidenav{max-height:100vh}}h2,h3{margin-left:10px;justify-content:right}\n"], dependencies: [{ kind: "directive", type: i2$1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i2$1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: i5$1.MatNavList, selector: "mat-nav-list", exportAs: ["matNavList"] }, { kind: "component", type: i5$1.MatListItem, selector: "mat-list-item, a[mat-list-item], button[mat-list-item]", inputs: ["activated"], exportAs: ["matListItem"] }] });
1554
+ SideNavigationComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: SideNavigationComponent, deps: [{ token: EntryService }, { token: i1$4.Router }, { token: IdentityService }, { token: i0.Renderer2 }], target: i0.ɵɵFactoryTarget.Component });
1555
+ SideNavigationComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.1.4", type: SideNavigationComponent, selector: "app-side-navigation", viewQueries: [{ propertyName: "divNav", first: true, predicate: ["navcontainer"], descendants: true }], ngImport: i0, template: "<div class=\"sidenav no-scrollbar\">\n <div style=\"margin-top: 20px;\">\n <mat-form-field style=\"width: 100%\">\n <mat-label>Search</mat-label>\n <input matInput [formControl]=\"searchControl\" (ngModelChange)=\"onSearchChange($event)\">\n </mat-form-field>\n </div>\n\n <div #navcontainer class=\"navcontainer\"\n [@sideNavAnimation]=\"state\"\n >\n <mat-nav-list\n *ngFor=\"let container of entriesByMonthAndYear\"\n >\n <h3>{{getMonthAndYearFromKey(container.month_year)}}</h3>\n <a mat-list-item *ngFor=\"let entry of container.entries\" href=\"javascript:void(0)\" (click)=\"routeTo(entry)\">{{entry.title}}</a>\n </mat-nav-list>\n\n </div>\n\n <ng-container *ngIf=\"identity?.id === 1\">\n <h2>Misc</h2>\n\n <mat-nav-list>\n <a mat-list-item href=\"javascript:void(0);\" (click)=\"routeTo(null)\">Create</a>\n </mat-nav-list>\n </ng-container>\n <h3 *ngIf=\"identity\">Logged in as {{identity?.email}}</h3>\n</div>\n\n", styles: [".sidenav{max-height:calc(100vh - 100px)}@media screen and (max-height: 560px){.sidenav{max-height:100vh}}h2,h3{margin-left:10px;justify-content:right}\n"], dependencies: [{ kind: "directive", type: i2$1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i2$1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i6$1.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i6$1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i6$1.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }, { kind: "directive", type: i9.MatInput, selector: "input[matInput], textarea[matInput], select[matNativeControl], input[matNativeControl], textarea[matNativeControl]", inputs: ["disabled", "id", "placeholder", "name", "required", "type", "errorStateMatcher", "aria-describedby", "value", "readonly"], exportAs: ["matInput"] }, { kind: "component", type: i10.MatFormField, selector: "mat-form-field", inputs: ["hideRequiredMarker", "color", "floatLabel", "appearance", "subscriptSizing", "hintLabel"], exportAs: ["matFormField"] }, { kind: "directive", type: i10.MatLabel, selector: "mat-label" }, { kind: "component", type: i8$1.MatNavList, selector: "mat-nav-list", exportAs: ["matNavList"] }, { kind: "component", type: i8$1.MatListItem, selector: "mat-list-item, a[mat-list-item], button[mat-list-item]", inputs: ["activated"], exportAs: ["matListItem"] }], animations: [
1556
+ trigger('sideNavAnimation', [
1557
+ state('in', style({ transform: 'translateX(0%)' })),
1558
+ state('out', style({ transform: 'translateX(110%)' })),
1559
+ transition('in => out', [
1560
+ animate('100ms ease-out', style({ transform: 'translateX(110%)' }))
1561
+ ]),
1562
+ transition('out => in', [
1563
+ animate('100ms ease-in', style({ transform: 'translateX(0%)' }))
1564
+ ])
1565
+ ]),
1566
+ ] });
1512
1567
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: SideNavigationComponent, decorators: [{
1513
1568
  type: Component,
1514
- args: [{ selector: 'app-side-navigation', template: "<div class=\"sidenav no-scrollbar\">\n <mat-nav-list *ngFor=\"let container of entriesByMonthAndYear\">\n <h3>{{getMonthAndYearFromKey(container.month_year)}}</h3>\n <a mat-list-item *ngFor=\"let entry of container.entries\" href=\"javascript:void(0)\" (click)=\"routeTo(entry)\">{{entry.title}}</a>\n </mat-nav-list>\n\n <ng-container *ngIf=\"identity?.id === 1\">\n <h2>Misc</h2>\n\n <mat-nav-list>\n <a mat-list-item href=\"javascript:void(0);\" (click)=\"routeTo(null)\">Create</a>\n </mat-nav-list>\n </ng-container>\n <h3 *ngIf=\"identity\">Logged in as {{identity?.email}}</h3>\n</div>\n\n", styles: [".sidenav{max-height:calc(100vh - 100px)}@media screen and (max-height: 560px){.sidenav{max-height:100vh}}h2,h3{margin-left:10px;justify-content:right}\n"] }]
1515
- }], ctorParameters: function () { return [{ type: EntryService }, { type: i1$4.Router }, { type: IdentityService }]; } });
1569
+ args: [{ selector: 'app-side-navigation', animations: [
1570
+ trigger('sideNavAnimation', [
1571
+ state('in', style({ transform: 'translateX(0%)' })),
1572
+ state('out', style({ transform: 'translateX(110%)' })),
1573
+ transition('in => out', [
1574
+ animate('100ms ease-out', style({ transform: 'translateX(110%)' }))
1575
+ ]),
1576
+ transition('out => in', [
1577
+ animate('100ms ease-in', style({ transform: 'translateX(0%)' }))
1578
+ ])
1579
+ ]),
1580
+ ], template: "<div class=\"sidenav no-scrollbar\">\n <div style=\"margin-top: 20px;\">\n <mat-form-field style=\"width: 100%\">\n <mat-label>Search</mat-label>\n <input matInput [formControl]=\"searchControl\" (ngModelChange)=\"onSearchChange($event)\">\n </mat-form-field>\n </div>\n\n <div #navcontainer class=\"navcontainer\"\n [@sideNavAnimation]=\"state\"\n >\n <mat-nav-list\n *ngFor=\"let container of entriesByMonthAndYear\"\n >\n <h3>{{getMonthAndYearFromKey(container.month_year)}}</h3>\n <a mat-list-item *ngFor=\"let entry of container.entries\" href=\"javascript:void(0)\" (click)=\"routeTo(entry)\">{{entry.title}}</a>\n </mat-nav-list>\n\n </div>\n\n <ng-container *ngIf=\"identity?.id === 1\">\n <h2>Misc</h2>\n\n <mat-nav-list>\n <a mat-list-item href=\"javascript:void(0);\" (click)=\"routeTo(null)\">Create</a>\n </mat-nav-list>\n </ng-container>\n <h3 *ngIf=\"identity\">Logged in as {{identity?.email}}</h3>\n</div>\n\n", styles: [".sidenav{max-height:calc(100vh - 100px)}@media screen and (max-height: 560px){.sidenav{max-height:100vh}}h2,h3{margin-left:10px;justify-content:right}\n"] }]
1581
+ }], ctorParameters: function () { return [{ type: EntryService }, { type: i1$4.Router }, { type: IdentityService }, { type: i0.Renderer2 }]; }, propDecorators: { divNav: [{
1582
+ type: ViewChild,
1583
+ args: ['navcontainer', { static: false }]
1584
+ }] } });
1516
1585
 
1517
1586
  class MainComponent {
1518
1587
  constructor(router) {