-
-
Notifications
You must be signed in to change notification settings - Fork 217
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor Generator component with AngularGenerator
- Loading branch information
Showing
8 changed files
with
207 additions
and
159 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
44 changes: 44 additions & 0 deletions
44
src/main/webapp/app/springboot/primary/angular-generator/AngularGenerator.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,44 @@ | ||
import { defineComponent, inject, ref } from 'vue'; | ||
import { AngularService } from '@/springboot/domain/client/AngularService'; | ||
import { ProjectToUpdate, toProject } from '@/springboot/primary/ProjectToUpdate'; | ||
import { Logger } from '@/common/domain/Logger'; | ||
|
||
export default defineComponent({ | ||
name: 'AngularGeneratorComponent', | ||
|
||
props: { | ||
project: { | ||
type: Object, | ||
required: true, | ||
}, | ||
}, | ||
|
||
setup(props) { | ||
const logger = inject('logger') as Logger; | ||
const angularService = inject('angularService') as AngularService; | ||
|
||
const selectorPrefix = 'angular-generator'; | ||
const isAngularWithStyle = ref<boolean>(false); | ||
|
||
const addAngular = async (): Promise<void> => { | ||
if (props.project.folder !== '') { | ||
if (isAngularWithStyle.value) { | ||
await angularService | ||
.addWithStyle(toProject(props.project as ProjectToUpdate)) | ||
.catch(error => logger.error('Adding Angular with style to project failed', error)); | ||
} else { | ||
await angularService | ||
.add(toProject(props.project as ProjectToUpdate)) | ||
.catch(error => logger.error('Adding Angular to project failed', error)); | ||
} | ||
} | ||
}; | ||
|
||
return { | ||
selectorPrefix, | ||
isAngularWithStyle, | ||
addAngular, | ||
props, | ||
}; | ||
}, | ||
}); |
28 changes: 28 additions & 0 deletions
28
src/main/webapp/app/springboot/primary/angular-generator/AngularGenerator.vue
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,28 @@ | ||
<template> | ||
<div id="v-pills-angular" class="tab-pane fade" role="tabpanel" aria-labelledby="v-pills-settings-tab"> | ||
<div class="list-group--inline py-2"> | ||
<label for="angular-with-style" class="list-group-item gap-3"> | ||
<input | ||
id="angular-with-style" | ||
v-model="isAngularWithStyle" | ||
type="checkbox" | ||
name="angular-with-style" | ||
class="form-check-input flex-shrink-0" | ||
/> | ||
<span class="form-checked-content"> | ||
<strong>Add Angular style</strong> | ||
</span> | ||
</label> | ||
</div> | ||
<button | ||
id="angular" | ||
class="btn btn-outline-primary" | ||
:data-selector="selectorPrefix + '.add-angular-button'" | ||
@click.prevent="addAngular" | ||
> | ||
Generate Angular | ||
</button> | ||
</div> | ||
</template> | ||
|
||
<script lang="ts" src="./AngularGenerator.component.ts"></script> |
4 changes: 4 additions & 0 deletions
4
src/main/webapp/app/springboot/primary/angular-generator/index.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,4 @@ | ||
import AngularGeneratorComponent from './AngularGenerator.component'; | ||
import AngularGeneratorVue from './AngularGenerator.vue'; | ||
|
||
export { AngularGeneratorComponent, AngularGeneratorVue }; |
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
Oops, something went wrong.