1
0
mirror of https://github.com/devcode-it/openstamanager.git synced 2025-02-23 14:57:46 +01:00

fix: Alert e animazione success

Alert:
- Controllo aggiuntivo sul caricamento dell'animazione (è stata definita o no?)
- Il pulsante OK viene ora mostrtao solo quando non ci sono animazioni già definite
This commit is contained in:
Maicol Battistini 2021-11-10 16:41:42 +01:00
parent 868a57b2a4
commit 706662d2ca
No known key found for this signature in database
GPG Key ID: 4FDB0F87CDB1D34A
2 changed files with 978 additions and 13 deletions

View File

@ -1,3 +1,5 @@
import '@material/mwc-dialog';
import {type Cash} from 'cash-dom/dist/cash';
import {uniqueId} from 'lodash-es';
import Lottie from 'lottie-web';
@ -42,13 +44,13 @@ export default class Alert extends Component implements ClassComponent<{
{vnode.children}
</div>
<mwc-button label={__('OK')} slot="primaryAction" dialogAction="ok"/>
${actions}
{actions.length > 0 ? actions : <mwc-button label={__('OK')} slot="primaryAction" dialogAction="ok"/>}
</mwc-dialog>
);
}
oninit(vnode) {
super.oninit(vnode);
if (this.attrs.get('id')) {
this.attrs.put('id', uniqueId('dialog_'));
}
@ -57,16 +59,22 @@ export default class Alert extends Component implements ClassComponent<{
oncreate(vnode) {
const dialog: Cash = $(`#${this.attrs.get('id')}`);
const animation = Lottie.loadAnimation({
container: dialog.find('.graphic')[0],
renderer: 'svg',
loop: false,
autoplay: false,
path: new URL(`./animations/${this.attrs.pull('icon')}.png`, import.meta.url).href
});
if (this.attrs.has('icon')) {
const animation = Lottie.loadAnimation({
container: dialog.find('.graphic')[0],
renderer: 'svg',
loop: false,
autoplay: false,
path: new URL(`/animations/${this.attrs.pull('icon')}.json`, import.meta.url).href
});
dialog.on('opened', () => {
animation.play();
});
dialog.on('opening', () => {
animation.goToAndStop(0);
});
dialog.on('opened', () => {
animation.play();
});
}
}
}

File diff suppressed because one or more lines are too long