Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/app/pages/blank/blank.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,16 @@ import { BlankComponent } from './blank.component';
import { BlankInfoComponent } from './shared/components/blank-info/blank-info.component';
import { RouterModule, Routes } from "@angular/router";
import { SharedModule } from "../../shared/shared.module";
import { BlankInvalidInfoComponent } from './shared/components/blank-invalid-info/blank-invalid-info.component';

const routes: Routes = [
{
path: '', component: BlankComponent, children: [
{
path: ':id', component: BlankInfoComponent, pathMatch: 'full'
},
{
path: 'wrong/:id', component: BlankInfoComponent, pathMatch: 'full'
}
]
}
Expand All @@ -18,7 +22,8 @@ const routes: Routes = [
@NgModule({
declarations: [
BlankComponent,
BlankInfoComponent
BlankInfoComponent,
BlankInvalidInfoComponent,
],
imports: [
CommonModule,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<p>blank-invalid-info works!</p>
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { Component, OnInit } from '@angular/core';

@Component({
selector: 'app-blank-invalid-info',
templateUrl: './blank-invalid-info.component.html',
styleUrls: ['./blank-invalid-info.component.scss']
})
export class BlankInvalidInfoComponent implements OnInit {

constructor() { }

ngOnInit(): void {
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -82,46 +82,57 @@ <h2 class="test__subtitle">
</ng-container>
</div>

<!-- <ng-container *ngIf="test.wrongBlanks.length > 0">-->
<ng-container *ngIf="test.invalidBlanks.length > 0">

<!-- <div class="test-wrong">-->
<div class="test-wrong" @animateOut>

<!-- <h2 class="test-wrong__subtitle">-->
<!-- Непроверенные бланки-->
<!-- </h2>-->
<h2 class="test-wrong__subtitle">
Непроверенные бланки
</h2>

<!-- <ul class="test__wrong test-wrong__list test-list">-->
<ul class="test__wrong test-wrong__list test-list">

<!-- <ng-container *ngFor="let blank of test.wrongBlanks; let i = index">-->
<!-- <li class="test-list__item test-wrong__item">-->
<!-- <div class="test-list__number test-wrong__number">-->
<!-- <span>{{ i + 1 }}.</span>-->
<!-- </div>-->
<ng-container *ngFor="let blank of test.invalidBlanks; let i = index">
<li class="test-list__item test-wrong__item" @animateOut>
<div class="test-list__number test-wrong__number">
<span>{{ i + 1 }}.</span>
</div>

<button
type="button"
class="test-list__author test-wrong__author"
(click)="showInvalidBlank(blank.pk)"
>
<span>Неизвестно</span>
</button>

<!-- <button-->
<!-- type="button"-->
<!-- class="test-list__author test-wrong__author"-->
<!-- (click)="showWrongBlank(blank.pk)"-->
<!-- >-->
<!-- <span>Неизвестно</span>-->
<!-- </button>-->
<div class="test-list__right test-wrong__right">
{{ blank.created_at.getDate() | number:'2.0' }}.{{ blank.created_at.getMonth() + 1 | number:'2.0' }}.{{ blank.created_at.getFullYear() }}
</div>

<!-- <div class="test-list__right test-wrong__right">-->
<!-- {{ blank.createdAt.getDate() | number:'2.0' }}.{{ blank.createdAt.getMonth() + 1 | number:'2.0' }}.{{ blank.createdAt.getFullYear() }}-->
<!-- </div>-->
<button type="button" class="test-list__delete test-wrong__delete" (click)="deleteInvalidBlank(i)">
<img src="assets/images/icons/deleteGrey.svg" alt="">
<img src="assets/images/icons/delete-red.svg" alt="">
</button>

<!-- <button type="button" class="test-list__delete test-wrong__delete" (click)="deleteWrongBlank(i)">-->
<!-- <img src="assets/images/icons/deleteGrey.svg" alt="">-->
<!-- <img src="assets/images/icons/delete-red.svg" alt="">-->
<!-- </button>-->
</li>
</ng-container>

<!-- </li>-->
<!-- </ng-container>-->
</ul>

<!-- </ul>-->
<!-- </div>-->
<div class="test-wrong__buttons">
<div class="test-wrong__button">
<app-button
mode="red"
(clickEvent)="deleteAllInvalid()"
>
удалить все
</app-button>
</div>
</div>
</div>

<!-- </ng-container>-->
</ng-container>


<div class="test__delete">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,10 @@
&__right {
color: $textGrey;
}

&__buttons {
margin-top: 2rem;
}
}

.test-assessment {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,22 +137,22 @@ export class TestInfoComponent implements OnInit {
})
}

protected deleteWrongBlank(i: number) {
const blank = this.test.wrongBlanks[i]
protected deleteInvalidBlank(i: number) {
const blank = this.test.invalidBlanks[i]
this._confirmService.createConfirm({
message: `Вы действительно хотите удалить бланк от ${
(blank.createdAt.getDate() < 10 ? '0' : '') + blank.createdAt.getDate()}.${
(blank.createdAt.getMonth() + 1 < 10 ? '0' : '') + (blank.createdAt.getMonth() + 1)}.${
blank.createdAt.getFullYear()}?`,
(blank.created_at.getDate() < 10 ? '0' : '') + blank.created_at.getDate()}.${
(blank.created_at.getMonth() + 1 < 10 ? '0' : '') + (blank.created_at.getMonth() + 1)}.${
blank.created_at.getFullYear()}?`,
buttonText: 'удалить'
})
.subscribe(confirmed => {
if (!confirmed)
return

this._blankService.deleteWrongBlank(blank.pk)
this._blankService.deleteInvalidBlank(blank.pk)
.subscribe(() => {
this.test.wrongBlanks.splice(i, 1)
this.test.invalidBlanks.splice(i, 1)
this._cd.markForCheck()
})
})
Expand All @@ -169,11 +169,28 @@ export class TestInfoComponent implements OnInit {
this._router.navigate(['blank', pkBlank], extras)
}

protected showWrongBlank(pkBlank: number) {
protected showInvalidBlank(pkBlank: number) {
// todo
}

protected navigateClass() {
this._router.navigate(['/', 'class', this.classInfo.pk])
}

protected deleteAllInvalid() {
this._confirmService.createConfirm({
message: `Вы действительно хотите удалить все непроверенные бланки?`,
buttonText: 'удалить'
})
.subscribe(confirmed => {
if (!confirmed)
return

this._blankService.deleteInvalidBlanks(this.test.invalidBlanks)
.subscribe(() => {
this.test.invalidBlanks = []
this._cd.markForCheck()
})
})
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,6 @@ export class TestResultComponent implements OnInit {
}

protected navigateTest() {
this._router.navigate(['/', 'test', this.blanks[0].test])
this._router.navigate(['/', 'test', getParamFromRoute(this._route)])
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export class BlankViewComponent implements OnChanges {
if (!changes?.['view']?.currentValue)
return

console.log(this.view)
this.resultView = calculateResult(changes?.['view']?.currentValue.blank)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,13 @@ export class BlanksViewComponent implements AfterViewInit, OnChanges {
if (!changes?.['blanks'].currentValue || changes?.['blanks'].firstChange)
return

this.createView(this.blanks[this.showIndex], this._showDetail)
if (this.blanks.length > this.showIndex)
this.createView(this.blanks[this.showIndex], this._showDetail)
}

public ngAfterViewInit(): void {
this.createView(this.blanks[this.showIndex])
if (this.blanks.length > this.showIndex)
this.createView(this.blanks[this.showIndex])
}

private createView(blank: IBlankParsed, showDetail: boolean = false) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { IBlankInvalidRequest } from "../../interfaces/Tests/Blanks/IBlankInvalidRequest";
import { IBlankInvalidParsed } from "../../interfaces/Tests/Blanks/IBlankInvalidParsed";

export function translateWrongBlanksFromRequest(blanks: IBlankInvalidRequest[]): IBlankInvalidParsed[] {
export function translateInvalidBlanksFromRequest(blanks: IBlankInvalidRequest[]): IBlankInvalidParsed[] {
return blanks.map(blank => ({
...blank,
createdAt: new Date(blank.createdAt)
created_at: new Date(blank.created_at)
}))
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export interface IBlankInvalidParsed {
pk: number
createdAt: Date
created_at: Date
image: string
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export interface IBlankInvalidRequest {
pk: number
createdAt: number
created_at: number
image: string
}
2 changes: 1 addition & 1 deletion src/app/shared/interfaces/Tests/Tests/ITestAllInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ import { IBlankInvalidParsed } from "../Blanks/IBlankInvalidParsed";

export interface ITestAllInfo extends ITest {
blanks: IBlankParsed[]
wrongBlanks: IBlankInvalidParsed[]
invalidBlanks: IBlankInvalidParsed[]
}
51 changes: 20 additions & 31 deletions src/app/shared/services/blank.service.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Injectable } from '@angular/core';
import { HttpService } from "./infrastructure/http.service";
import { IBlankRequest } from "../interfaces/Tests/Blanks/IBlankRequest";
import { delay, forkJoin, map, Observable, of, switchMap, take } from "rxjs";
import { forkJoin, map, Observable, of, switchMap, take, zip } from "rxjs";
import { IBlankParsed } from "../interfaces/Tests/Blanks/IBlankParsed";
import { environment } from "../../../environments/environment";
import { IBlankWithAuthor } from "../interfaces/Tests/Blanks/IBlankWithAuthor";
Expand All @@ -10,8 +10,9 @@ import { StudentService } from "./student.service";
import { PatternService } from "./pattern.service";
import { sortStrings } from "../functions/application/sortStrings";
import { IBlankInvalidParsed } from "../interfaces/Tests/Blanks/IBlankInvalidParsed";
import { translateWrongBlanksFromRequest } from "../functions/blanks/translateWrongBlanksFromRequest";
import { translateInvalidBlanksFromRequest } from "../functions/blanks/translateInvalidBlanksFromRequest";
import { BlankUpdate } from "../interfaces/Tests/Blanks/BlankUpdate";
import { IBlankInvalidRequest } from "../interfaces/Tests/Blanks/IBlankInvalidRequest";

@Injectable({
providedIn: 'root'
Expand All @@ -23,8 +24,8 @@ export class BlankService {
private _pattern: PatternService
) { }

public deleteBlank(blankPk: number): Observable<void> {
return this._http.Delete<void>(`blank/${blankPk}`)
public deleteBlank(pkBlank: number): Observable<void> {
return this._http.Delete<void>(`blank/${pkBlank}`)
.pipe(take(1))
}

Expand All @@ -39,38 +40,26 @@ export class BlankService {
)
}

public getWrongBlanks(pkTest: number): Observable<IBlankInvalidParsed[]> {
return of([
{
pk: 1,
createdAt: Date.now(),
image: "",
},
{
pk: 1,
createdAt: new Date().setDate(new Date().getDate() - 7),
image: "",
},
{
pk: 1,
createdAt: new Date().setDate(new Date().getDate() - 14),
image: "",
},
{
pk: 1,
createdAt: new Date().setDate(new Date().getDate() - 21),
image: "",
}])
public getInvalidBlanks(pkTest: number, temporary = false): Observable<IBlankInvalidParsed[]> {
return this._http.Get<IBlankInvalidRequest[]>(
(temporary ? "temp/" : "") + `test/${pkTest}/invalid_blanks`,
{ withCredentials: !temporary }
)
.pipe(
map(blanks => translateWrongBlanksFromRequest(blanks)),
take(1),
map(blanks => translateInvalidBlanksFromRequest(blanks)),
take(1)
)
}

public deleteWrongBlank(pkBlank: number): Observable<any> {
return of({})
public deleteInvalidBlank(pkBlank: number): Observable<void> {
return this._http.Delete<void>(`invalid_blank/${pkBlank}`)
.pipe(take(1))
}

public deleteInvalidBlanks(blanks: IBlankInvalidParsed[]): Observable<void> {
return zip(...blanks.map(blank => this.deleteInvalidBlank(blank.pk)))
.pipe(
delay(100),
map(() => undefined),
take(1)
)
}
Expand Down
2 changes: 1 addition & 1 deletion src/app/shared/services/test.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export class TestService {
switchMap(test => {
return forkJoin({
blanks: this._blank.getBlanks(pkTest),
wrongBlanks: this._blank.getWrongBlanks(pkTest),
invalidBlanks: this._blank.getInvalidBlanks(pkTest),
})
.pipe(
map(blanksAll => ({
Expand Down
2 changes: 1 addition & 1 deletion src/styles/classes.scss
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@

%block-red {
border-radius: 35px;
border: 4.045px solid $red;
border: 3px solid $red;
background: #F6F6F6;
box-shadow: 4.44px 6.21px 16.86px 0px rgba(0, 0, 0, 0.25);
padding: 2.5rem 2.9rem;
Expand Down