[rg-router] Fix taglist update

This commit is contained in:
Joxit 2016-06-03 22:37:22 +02:00
parent 28649c6893
commit e45c107fe7
3 changed files with 28 additions and 12 deletions

25
app.tag
View file

@ -19,10 +19,25 @@
<taglist if="{rg.router.current.name == 'taglist'}"></taglist> <taglist if="{rg.router.current.name == 'taglist'}"></taglist>
<script> <script>
this.mixin('rg.router'); this.mixin('rg.router');
this.router.add({name: 'home', url: ''}); this.router.add({name: 'home', url: ''});
this.router.add({name: 'taglist', url: '/taglist/:repository/:image'}); this.router.add({name: 'taglist', url: '/taglist/:repository/:image'});
this.router.on('go', state => {
this.router.start(); switch (state.name) {
case 'taglist':
if (registryUI.taglist.display) {
registryUI.taglist.display();
}
break;
case 'home':
if (catalog.display) {
catalog.display();
}
break;
default:
}
})
this.router.start();
</script> </script>
</app> </app>

View file

@ -80,8 +80,7 @@
componentHandler.upgradeElements(this['catalog-tag']); componentHandler.upgradeElements(this['catalog-tag']);
}); });
catalog.go = function (image) { catalog.go = function (image) {
rg.router.go('taglist', rg.router.go('taglist', {
{
repository: image.split('/')[0], repository: image.split('/')[0],
image: image.split('/')[1] image: image.split('/')[1]
}); });

View file

@ -48,10 +48,7 @@
<script> <script>
registryUI.taglist.instance = this; registryUI.taglist.instance = this;
registryUI.taglist.display = function () {
registryUI.taglist.instance.update();
this.on('updated', function () {
componentHandler.upgradeElements(this['taglist-tag']);
if (rg.router.current && rg.router.current.name == 'taglist') { if (rg.router.current && rg.router.current.name == 'taglist') {
name = rg.router.current.params.repository + (rg.router.current.params.image name = rg.router.current.params.repository + (rg.router.current.params.image
? '/' + rg.router.current.params.image ? '/' + rg.router.current.params.image
@ -92,8 +89,13 @@
oReq.withCredentials = false; oReq.withCredentials = false;
oReq.send(); oReq.send();
} }
};
registryUI.taglist.display();
registryUI.taglist.instance.update();
this.on('updated', function () {
componentHandler.upgradeElements(this['taglist-tag']);
}); });
registryUI.taglist.reverse = function (th) { registryUI.taglist.reverse = function (th) {
if (th.className == 'mdl-data-table__header--sorted-ascending') { if (th.className == 'mdl-data-table__header--sorted-ascending') {
th.className = 'mdl-data-table__header--sorted-descending'; th.className = 'mdl-data-table__header--sorted-descending';