Created
July 23, 2017 10:51
-
-
Save jsobell/8ce59e0e78f7ddb75108205d4304f92e to your computer and use it in GitHub Desktop.
DI inheritance
This file contains hidden or 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
<template> | |
<section> | |
<h2>${heading}</h2> | |
Caja | |
<select value.bind="cobranza.CajaId"> | |
<option value="0">Seleccionar Caja</option> | |
<option repeat.for="caja of cajas" model.bind="caja.CajaId">${caja.Nombre}</option> | |
</select> | |
Cliente | |
<select class="F24" value.bind="cobranza.ClienteId"> | |
<option value="0">Seleccionar cliente</option> | |
<option repeat.for="cliente of clientes" model.bind="cliente.ClienteId">${cliente.Nombre} ${cliente.Apellido}</option> | |
</select> | |
Monto | |
<input type="number" value.bind="cobranza.Monto"></input> | |
<button click.delegate="cobrar()" disabled.bind="cobrando">Cobrar</button> | |
</section> | |
</template> |
This file contains hidden or 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
import {DialogController} from 'aurelia-dialog'; | |
import { | |
inject, | |
computedFrom, | |
bindable, | |
customElement, | |
bindingMode } from 'aurelia-framework'; | |
@customElement('agregar-cobranza') | |
export class AgregarCobranza { | |
@bindable({ defaultBindingMode: bindingMode.twoWay }) cobranza; | |
@bindable({ defaultBindingMode: bindingMode.twoWay }) dialogController; | |
cobrando = false; | |
constructor() { | |
this.heading = 'Cobrar'; | |
console.log(this.dialogController); | |
console.log(this.cobranza); | |
} | |
cobrar() { | |
this.dialogController.ok(); | |
} | |
} |
This file contains hidden or 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
<template> | |
<h1>Dialog Repro</h1> | |
<button click.delegate="submit()">Open Dialog</button> | |
</template> |
This file contains hidden or 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
import {DialogService} from 'aurelia-dialog'; | |
import {Prompt} from './prompt'; | |
export class App { | |
person = { name: 'Test' }; | |
static inject = [DialogService]; | |
constructor(dialogService) { | |
this.dialogService = dialogService; | |
} | |
submit(){ | |
this.dialogService.open({ viewModel: Prompt, model: this.person}).then(response => { | |
if (!response.wasCancelled) { | |
console.log('good'); | |
} else { | |
console.log('bad'); | |
} | |
console.log(response.output); | |
}); | |
} | |
} |
This file contains hidden or 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
<!doctype html> | |
<html> | |
<head> | |
<title>Aurelia</title> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
</head> | |
<body aurelia-app="main"> | |
<h1>Loading...</h1> | |
<script src="https://cdn.rawgit.com/jdanyow/aurelia-bundle/v1.0.3/jspm_packages/system.js"></script> | |
<script src="https://cdn.rawgit.com/jdanyow/aurelia-bundle/v1.0.3/config.js"></script> | |
<script> | |
System.import('aurelia-bootstrapper'); | |
</script> | |
</body> | |
</html> |
This file contains hidden or 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
export function configure(aurelia) { | |
aurelia.use | |
.standardConfiguration() | |
.developmentLogging() | |
.plugin('aurelia-dialog'); | |
aurelia.start().then(a => a.setRoot()); | |
} |
This file contains hidden or 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
<template> | |
<require from="./agregarCobranza"></require> | |
<ai-dialog> | |
<ai-dialog-body> | |
<h2>Agregar cobranza</h2> | |
<agregar-cobranza cobranza.one-way="cobranza" dialog-controller.one-way="controller"></agregar-cobranza> | |
</ai-dialog-body> | |
</ai-dialog> | |
</template> |
This file contains hidden or 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
import {bindable} from 'aurelia-framework'; | |
import {DialogController} from 'aurelia-dialog'; | |
export class Prompt { | |
@bindable cobrado; | |
@bindable cobranza; | |
static inject = [DialogController]; | |
constructor(controller){ | |
this.controller = controller; | |
this.cobranza = {}; | |
} | |
activate(model){ | |
this.cobranza.CajaId = model; | |
} | |
canDeactivate(){ | |
if(!this.cobrado){ | |
var resp = confirm('¿Desea salir sin guardar la cobranza?'); | |
if(resp === true) | |
return resp; | |
else | |
return false; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment