-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(message-box-dialog): first commit
- Loading branch information
Showing
25 changed files
with
459 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
name: Test message-box-dialog | ||
|
||
on: | ||
workflow_dispatch: | ||
workflow_call: | ||
push: | ||
branches: | ||
- '**' | ||
tags-ignore: | ||
- '**' | ||
paths: | ||
- '.github/workflows/ci_test_message-box-dialog.yml' | ||
- 'projects/message-box-dialog/**' | ||
|
||
concurrency: | ||
group: ci-test-message-box-dialog-group-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
ci_test_message-box-dialog: | ||
if: "${{ !contains(github.event.head_commit.message, 'chore(release): publish') }}" | ||
uses: dsi-hug/action/.github/workflows/action.yml@v1 | ||
with: | ||
working-directory: projects/message-box-dialog | ||
runs-on: '["ubuntu-latest", "macos-latest", "windows-latest"]' | ||
node-versions: '[18, 20]' |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
@hug/message-box-dialog | ||
======= | ||
|
||
The sources for this package are in the main [DSI-HUG/ngx-components](https://github.com/dsi-hug/ngx-components) repo. Please file issues and pull requests against that repo. | ||
|
||
License: GPL-3.0-only |
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,45 @@ | ||
// Karma configuration file, see link for more information | ||
// https://karma-runner.github.io/1.0/config/configuration-file.html | ||
|
||
module.exports = config => { | ||
config.set({ | ||
basePath: '', | ||
frameworks: ['jasmine', '@angular-devkit/build-angular'], | ||
plugins: [ | ||
require('karma-jasmine'), | ||
require('karma-chrome-launcher'), | ||
require('karma-jasmine-html-reporter'), | ||
require('karma-coverage'), | ||
require('@angular-devkit/build-angular/plugins/karma') | ||
], | ||
client: { | ||
jasmine: { | ||
// you can add configuration options for Jasmine here | ||
// the possible options are listed at https://jasmine.github.io/api/edge/Configuration.html | ||
// for example, you can disable the random execution with `random: false` | ||
// or set a specific seed with `seed: 4321` | ||
}, | ||
clearContext: false // leave Jasmine Spec Runner output visible in browser | ||
}, | ||
jasmineHtmlReporter: { | ||
suppressAll: true // removes the duplicated traces | ||
}, | ||
coverageReporter: { | ||
dir: require('path').join(__dirname, '../../coverage/message-box-dialog'), | ||
subdir: '.', | ||
reporters: [ | ||
{ type: 'html' }, | ||
{ type: 'text-summary' } | ||
] | ||
}, | ||
reporters: ['progress', 'kjhtml'], | ||
port: 9876, | ||
colors: true, | ||
logLevel: config.LOG_INFO, | ||
autoWatch: true, | ||
browsers: ['Chrome'], | ||
singleRun: false, | ||
failOnEmptyTestSuite: false, | ||
restartOnFileChange: true | ||
}); | ||
}; |
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,15 @@ | ||
{ | ||
"$schema": "../../node_modules/ng-packagr/ng-package.schema.json", | ||
"dest": "../../dist/message-box-dialog", | ||
"assets": [ | ||
"CHANGELOG.md", | ||
{ | ||
"input": "src/", | ||
"glob": "_message-box-dialog-theme.scss", | ||
"output": "." | ||
} | ||
], | ||
"lib": { | ||
"entryFile": "src/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,45 @@ | ||
{ | ||
"name": "@hug/ngx-message-box-dialog", | ||
"version": "1.0.0", | ||
"description": "HUG Angular - message-box-dialog component", | ||
"homepage": "https://github.com/dsi-hug/ngx-components", | ||
"license": "GPL-3.0-only", | ||
"author": "HUG - Hôpitaux Universitaires Genève", | ||
"contributors": [ | ||
"badisi (https://github.com/badisi)", | ||
"vapkse (https://github.com/vapkse)" | ||
], | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/dsi-hug/ngx-components.git" | ||
}, | ||
"keywords": [ | ||
"angular", | ||
"material", | ||
"material design", | ||
"components" | ||
], | ||
"sideEffects": false, | ||
"scripts": { | ||
"lint": "eslint . --fix", | ||
"test": "ng test message-box-dialog", | ||
"test:ci": "ng test message-box-dialog --watch=false --browsers=ChromeHeadless", | ||
"build:ng": "ng build message-box-dialog -c=production", | ||
"build": "nx build:ng @hug/ngx-message-box-dialog --verbose", | ||
"release": "nx release -p=@hug/ngx-message-box-dialog --yes --verbose", | ||
"release:dry-run": "nx release -p=@hug/ngx-message-box-dialog --verbose --dry-run" | ||
}, | ||
"peerDependencies": { | ||
"@angular/common": ">= 14", | ||
"@angular/core": ">= 14", | ||
"@angular/material": ">= 14", | ||
"rxjs": ">= 7.0.0", | ||
"@hug/ngx-core": "1.1.5" | ||
}, | ||
"dependencies": { | ||
"tslib": "^2.6.3" | ||
}, | ||
"publishConfig": { | ||
"access": "public" | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
projects/message-box-dialog/src/_message-box-dialog-theme.scss
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,33 @@ | ||
@use '@angular/material' as mat; | ||
|
||
@mixin message-box-dialog-theme($theme) { | ||
$warn: map-get($theme, warn); | ||
|
||
.cdk-overlay-container { | ||
.cdk-overlay-pane { | ||
&.warning { | ||
app-message-box-dialog { | ||
.mat-toolbar { | ||
background-color: mat.get-color-from-palette(mat.$orange-palette, 500); | ||
} | ||
|
||
button.mat-primary { | ||
color: mat.get-color-from-palette(mat.$orange-palette, 500); | ||
} | ||
} | ||
} | ||
|
||
&.error { | ||
app-message-box-dialog { | ||
.mat-toolbar { | ||
background-color: mat.get-color-from-palette($warn); | ||
} | ||
|
||
button.mat-primary { | ||
color: mat.get-color-from-palette($warn); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
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 @@ | ||
export * from './message-box-dialog.component'; | ||
export * from './message-box-dialog.service'; | ||
export * from './message-box-dialog.model'; | ||
export * from './message-box-dialog.module'; |
18 changes: 18 additions & 0 deletions
18
projects/message-box-dialog/src/message-box-dialog.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,18 @@ | ||
<mat-toolbar class="dialog-toolbar" color="primary"> | ||
<span class="dialog-title" data-cy="confirmation-dialog-title">{{ dialogParams.title }}</span> | ||
<mat-icon class="dialog-action" mat-dialog-close="cancel">close</mat-icon> | ||
</mat-toolbar> | ||
|
||
<div class="dialog-container"> | ||
<div [innerHTML]="dialogParams.text"></div> | ||
</div> | ||
|
||
<div class="dialog-buttons"> | ||
<button type="button" id="cancelbtn" mat-button mat-dialog-close="cancel" *ngIf="hasControl('CANCEL')" color="primary" data-cy="cancel">Annuler</button> | ||
<button type="button" mat-button mat-dialog-close="ignore" *ngIf="hasControl('IGNORE')" color="primary" data-cy="ignore">Ignorer</button> | ||
<button type="button" mat-stroked-button default mat-dialog-close="retry" *ngIf="hasControl('RETRY')" color="primary" data-cy="retry">Recommencer</button> | ||
<button type="button" id="okbtn" mat-stroked-button mat-dialog-close="ok" *ngIf="hasControl('OK')" color="primary" data-cy="ok">Ok</button> | ||
<button type="button" mat-stroked-button mat-dialog-close="yes" *ngIf="hasControl('YES')" color="primary" data-cy="yes">Oui</button> | ||
<button type="button" mat-stroked-button mat-dialog-close="no" *ngIf="hasControl('NO')" color="primary" data-cy="no">Non</button> | ||
<button type="button" mat-stroked-button mat-dialog-close="continue" *ngIf="hasControl('CONTINUE')" color="primary" data-cy="continue">Continuer</button> | ||
</div> |
10 changes: 10 additions & 0 deletions
10
projects/message-box-dialog/src/message-box-dialog.component.scss
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,10 @@ | ||
app-message-box-dialog { | ||
padding-top: 1rem; | ||
|
||
.dialog-container { | ||
display: flex; | ||
flex-direction: column; | ||
margin: 1rem 1rem 0.5rem 1rem; | ||
max-height: 80vh; | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
projects/message-box-dialog/src/message-box-dialog.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,22 @@ | ||
import { ChangeDetectionStrategy, Component, Inject, ViewEncapsulation } from '@angular/core'; | ||
import { MAT_DIALOG_DATA } from '@angular/material/dialog'; | ||
|
||
import { MessageBoxDialogButtons, MessageBoxDialogData } from './message-box-dialog.model'; | ||
|
||
@Component({ | ||
selector: 'app-message-box-dialog', | ||
templateUrl: './message-box-dialog.component.html', | ||
styleUrls: ['./message-box-dialog.component.scss'], | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
encapsulation: ViewEncapsulation.None | ||
}) | ||
export class MessageBoxDialogComponent { | ||
public constructor( | ||
@Inject(MAT_DIALOG_DATA) protected dialogParams: MessageBoxDialogData | ||
) { } | ||
|
||
protected hasControl(key: 'OK' | 'CANCEL' | 'IGNORE' | 'RETRY' | 'YES' | 'NO' | 'CONTINUE'): boolean { | ||
// eslint-disable-next-line no-bitwise | ||
return !!this.dialogParams.buttons && (this.dialogParams.buttons & MessageBoxDialogButtons[key]) !== 0; | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
projects/message-box-dialog/src/message-box-dialog.model.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,17 @@ | ||
export type MessageBoxDialogResponse = 'ok' | 'cancel' | 'ignore' | 'retry' | 'yes' | 'no' | 'continue'; | ||
|
||
export enum MessageBoxDialogButtons { | ||
OK = 0x1, | ||
CANCEL = 0x2, | ||
IGNORE = 0x4, | ||
RETRY = 0x8, | ||
YES = 0x10, | ||
NO = 0x20, | ||
CONTINUE = 0x40 | ||
} | ||
|
||
export interface MessageBoxDialogData { | ||
title: string; | ||
text: string; | ||
buttons?: MessageBoxDialogButtons; | ||
} |
Oops, something went wrong.