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

File diff suppressed because one or more lines are too long