Skip to content

Commit 916eecd

Browse files
committed
add github action, enhance parser module
1 parent b8bd742 commit 916eecd

File tree

6 files changed

+74
-30
lines changed

6 files changed

+74
-30
lines changed

.github/workflows/publish.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Publish to NPM
2+
on:
3+
release:
4+
types: [created]
5+
jobs:
6+
build:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- name: Checkout
10+
uses: actions/checkout@v2
11+
- name: Setup Node
12+
uses: actions/setup-node@v2
13+
with:
14+
node-version: '16.x'
15+
registry-url: 'https://registry.npmjs.org'
16+
- name: Install dependencies and build 🔧
17+
run: npm ci && npm run build
18+
- name: Publish package on NPM 📦
19+
run: npm publish
20+
env:
21+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

package-lock.json

Lines changed: 13 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@godzilla-forms/parser",
3-
"version": "0.0.5",
3+
"version": "0.0.6",
44
"description": "Godzilla Forms parser library for angular",
55
"private": false,
66
"publishConfig": {
@@ -18,18 +18,18 @@
1818
"Godzilla",
1919
"Form Builder"
2020
],
21-
"author": "Abdullah Alhazmy",
21+
"author": "Alhazmy",
2222
"email": "[email protected]",
2323
"license": "MIT",
24-
"homepage": "https://github.com/alhazmy13/godzilla#readme",
24+
"homepage": "https://github.com/Godzilla-Forms/angular-parser#readme",
2525
"bugs": {
26-
"url": "https://github.com/alhazmy13/godzilla/issues"
26+
"url": "https://github.com/Godzilla-Forms/angular-parser/issues"
2727
},
2828
"peerDependencies": {
2929
"@angular/common": "^14.0.0",
3030
"@angular/core": "^14.0.0",
3131
"@angular/forms": "^14.0.0",
32-
"@godzilla-forms/core": "file:../core"
32+
"@godzilla-forms/core": "^0.0.3"
3333
},
3434
"devDependencies": {
3535
"@angular-devkit/build-angular": "^14.2.3",

src/components/form-parser.component.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ export class GodzillaFormsParserComponent implements OnChanges {
2727

2828
ngOnChanges(changes: SimpleChanges) {
2929
this.createForm(this.jsonForm);
30-
3130
}
3231

3332
/**
@@ -49,7 +48,13 @@ export class GodzillaFormsParserComponent implements OnChanges {
4948
}
5049
}
5150

51+
/**
52+
* Public function to notify the parser component to reset the form
53+
*/
54+
public notifyFormChanged(){
55+
this.createForm(this.jsonForm);
5256

57+
}
5358
/**
5459
* Public function to be called by another component to validate the form and emit
5560
* the form values
@@ -126,7 +131,7 @@ export class GodzillaFormsParserComponent implements OnChanges {
126131
this._godzillaLoader.getDataService(serviceName).then(data => {
127132
control.value.valueOptions = data;
128133
}).catch(err => {
129-
console.debug(err);
134+
console.error(err);
130135
})
131136
}
132137

src/parser.module.ts

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,43 @@
1-
import {NgModule} from "@angular/core";
2-
import {CommonModule} from "@angular/common";
3-
import {FormsModule, ReactiveFormsModule} from "@angular/forms";
4-
import {GodzillaFormsParserComponent} from "./components/form-parser.component";
5-
import {GodzillaLoaderService} from "./utils/services/loader.service";
1+
import { ModuleWithProviders, NgModule } from '@angular/core';
2+
import { CommonModule } from '@angular/common';
3+
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
4+
import { GodzillaFormsParserComponent } from './components/form-parser.component';
5+
import { GodzillaLoaderService } from './utils/services/loader.service';
6+
import { GODZILLA_OPTIONS, GodzillaOptions } from './utils/factory';
67

78

89
@NgModule({
910
imports: [
1011
CommonModule,
1112
FormsModule,
12-
ReactiveFormsModule,
13+
ReactiveFormsModule
1314
],
1415
declarations: [
15-
GodzillaFormsParserComponent,
16+
GodzillaFormsParserComponent
1617

1718
],
1819
exports: [
19-
GodzillaFormsParserComponent,
20-
20+
GodzillaFormsParserComponent
2121
],
2222
providers: [GodzillaLoaderService]
2323
})
24+
2425
export class GodzillaParserModule {
26+
public static forRoot(config?: GodzillaOptions): ModuleWithProviders<GodzillaParserModule> {
27+
return {
28+
ngModule: GodzillaParserModule,
29+
providers: [{
30+
provide: GODZILLA_OPTIONS,
31+
useValue: config
32+
}]
33+
};
34+
}
35+
36+
public static forChild(): ModuleWithProviders<GodzillaParserModule> {
37+
return {
38+
ngModule: GodzillaParserModule,
39+
providers: []
40+
};
41+
}
2542
}
43+

src/utils/services/loader.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import {Inject, Injectable, Injector, Optional} from "@angular/core";
22
import {GodzillaDataService, GodzillaFormCombinedValues} from "@godzilla-forms/core";
33
import {GODZILLA_OPTIONS, GodzillaOptions} from "../factory";
44

5-
@Injectable()
5+
@Injectable({providedIn: 'root'})
66
export class GodzillaLoaderService {
77

88
private readonly _options: GodzillaOptions = {}

0 commit comments

Comments
 (0)