-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #109 from stneveadomi/103-store-rules-in-settingsjson
Solution for Import / Export of rules
- Loading branch information
Showing
16 changed files
with
272 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,10 @@ | ||
<div class="main-container"> | ||
<div *ngIf="!extension.editMode" class="main-container"> | ||
<app-rule *ngFor="let r of $rules | async" [rule]="r"> </app-rule> | ||
<app-add-rule> </app-add-rule> | ||
</div> | ||
|
||
<div class="edit-mode-container" *ngIf="extension.editMode"> | ||
<app-edit-mode> </app-edit-mode> | ||
</div> | ||
|
||
<div #dropOverlay class="drop-overlay" *ngIf="showDropOverlay()"></div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
webview-ui/grepc-webview/src/app/edit-mode/edit-mode.component.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
.edit-block { | ||
height: 100%; | ||
width: 80%; | ||
display: inline-block; | ||
padding: 1em; | ||
margin: 1em; | ||
overflow-x: hidden; | ||
white-space: pre-wrap; | ||
} | ||
|
||
.invalid { | ||
border: 1px solid red; | ||
} |
8 changes: 8 additions & 0 deletions
8
webview-ui/grepc-webview/src/app/edit-mode/edit-mode.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<pre | ||
class="edit-block" | ||
[class.invalid]="!isValid" | ||
(blur)="onBlur($event.target)" | ||
tabindex="0" | ||
contenteditable | ||
>{{ ruleArray }} | ||
</pre> |
22 changes: 22 additions & 0 deletions
22
webview-ui/grepc-webview/src/app/edit-mode/edit-mode.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { EditModeComponent } from './edit-mode.component'; | ||
|
||
describe('EditModeComponent', () => { | ||
let component: EditModeComponent; | ||
let fixture: ComponentFixture<EditModeComponent>; | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
imports: [EditModeComponent], | ||
}).compileComponents(); | ||
|
||
fixture = TestBed.createComponent(EditModeComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
37 changes: 37 additions & 0 deletions
37
webview-ui/grepc-webview/src/app/edit-mode/edit-mode.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { Component, OnInit } from '@angular/core'; | ||
import { RuleService } from '../../services/rule.service'; | ||
|
||
@Component({ | ||
selector: 'app-edit-mode', | ||
standalone: true, | ||
imports: [], | ||
templateUrl: './edit-mode.component.html', | ||
styleUrl: './edit-mode.component.css', | ||
}) | ||
export class EditModeComponent implements OnInit { | ||
ruleArray = ''; | ||
isValid = true; | ||
|
||
constructor(protected ruleService: RuleService) {} | ||
|
||
ngOnInit() { | ||
this.ruleArray = JSON.stringify( | ||
this.ruleService.getRuleArray(), | ||
undefined, | ||
' ', | ||
).trim(); | ||
} | ||
|
||
onBlur(rules: EventTarget | null) { | ||
if (rules instanceof HTMLElement) { | ||
const htmlEvent = rules as HTMLElement; | ||
if ( | ||
(this.isValid = this.ruleService.areValidRules( | ||
htmlEvent.innerHTML, | ||
)) | ||
) { | ||
this.ruleService.pushNewRuleArray(htmlEvent.innerHTML); | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.