LT-67 Fixing navigation issues and implementing server's removal

This commit is contained in:
Bruno Alves de Faria authored and Erik Ziegler committed 2016-08-04 16:49:51 +02:00
1 parent 16a302e979
commit 1ca585bfb0
6 files changed
+37 -33

No files matched your search

@@ -3,7 +3,9 @@ Template.serverInformationDimse.onCreated(function() {
instance.peers = new ReactiveVar([]);
instance.autorun(function() {
var currentItem = instance.data.currentItem.get();
instance.peers.set(currentItem.peers || []);
if (currentItem) {
instance.peers.set(currentItem.peers || []);
}
});
});
@@ -25,7 +25,7 @@ Template.serverInformationForm.events({
console.log('>>>>ERROR', error);
}
instance.data.mode.set('list');
instance.data.resetState();
});
}
});
@@ -14,10 +14,10 @@
<td>{{this.type}}</td>
<td class="text-right">
<div class="btn-group" role="group" aria-label="Actions">
<button class="btn btn-sm btn-default editServer" {{tooltipTop "Edit"}}>
<button class="btn btn-sm btn-default js-edit-server" title="Edit">
<i class="fa fa-pencil"></i>
</button>
<button class="btn btn-sm btn-danger removeServer" {{tooltipTop "Remove"}}>
<button class="btn btn-sm btn-danger js-remove-server" title="Remove">
<i class="fa fa-trash"></i>
</button>
</div>
@@ -30,7 +30,7 @@
{{/each}}
</tbody>
</table>
<button class="btn btn-default addServer">
<button class="btn btn-default js-add-server">
<i class="fa fa-plus"></i> Add a new server
</button>
</template>
@@ -1,34 +1,24 @@
Template.serverInformationList.onRendered(function() {
var instance = Template.instance();
instance.$('[data-toggle="tooltip"]').tooltip({
container: 'body'
});
});
Template.serverInformationList.onDestroyed(function() {
var instance = Template.instance();
instance.$('[data-toggle="tooltip"]').tooltip('destroy');
});
Template.serverInformationList.helpers({
tooltipTop: function(title) {
return {
'data-toggle': 'tooltip',
'data-placement': 'top',
title: title
};
},
servers: function() {
return Servers.find().fetch();
}
});
Template.serverInformationList.events({
'click .addServer': function(event, instance) {
'click .js-add-server': function(event, instance) {
instance.data.mode.set('create');
},
'click .editServer': function(event, instance) {
'click .js-edit-server': function(event, instance) {
instance.data.currentItem.set(this);
instance.data.mode.set('edit');
},
'click .js-remove-server': function(event, instance) {
var id = this._id;
Meteor.call('removeServer', this._id, function(error) {
if (error) {
// TODO: check for errors: not-authorized, data-write
console.log('>>>>ERROR', error);
}
});
}
});
@@ -4,14 +4,17 @@ Template.serverInformationModal.onCreated(function() {
mode: new ReactiveVar('list'),
serverType: new ReactiveVar(null),
currentItem: new ReactiveVar(null),
$form: null
$form: null,
resetState: function() {
instance.container.mode.set('list');
instance.container.serverType.set(null);
instance.container.currentItem.set(null);
}
};
});
Template.serverInformationModal.events({
'click .js-back': function(event, instance) {
var container = instance.container;
container.mode.set('list');
container.serverType.set(null);
'click .js-back, click [data-dismiss=modal]': function(event, instance) {
instance.container.resetState();
}
});