浏览代码

added button to delete rooms on admin page

AkiraLaine 9 年之前
父节点
当前提交
3acd353086
共有 2 个文件被更改,包括 17 次插入1 次删除
  1. 16 0
      app/app.js
  2. 1 1
      app/templates/admin.html

+ 16 - 0
app/app.js

@@ -214,6 +214,12 @@ if (Meteor.isClient) {
         Meteor.subscribe("history");
     });
 
+    Template.dashboard.events({
+        "click #delete-room": function(){
+           console.log(type);
+        }
+    })
+
     Template.room.events({
         "click #add-song-button": function(e){
             e.preventDefault();
@@ -584,6 +590,11 @@ if (Meteor.isClient) {
                     $('#editModal').modal('hide');
                 });
             }
+        },
+        "click #delete-room": function(){
+            var typeDel = $(this)[0].type;
+            console.log(typeDel);
+            Meteor.call("deleteRoom", typeDel);
         }
     });
 
@@ -1343,6 +1354,11 @@ if (Meteor.isServer) {
             } else {
                 return false;
             }
+        },
+        deleteRoom: function(type){
+            Rooms.remove({type: type})
+            Playlists.remove({type: type});
+            Queues.remove({type: type});
         }
     });
 }

+ 1 - 1
app/templates/admin.html

@@ -49,7 +49,7 @@
                 <div class="col-md-8 col-md-offset-2 admin-playlist-panel">
                     <div class="panel panel-primary">
                         <div class="panel-heading">
-                            <h3 class="panel-title">{{type}} playlist</h3>
+                            <h3 class="panel-title"><span>{{type}}</span> playlist</h3><i id="delete-room" class="fa fa-times"></i>
                         </div>
                         <div class="panel-body admin-panel-body">
                             <table class="table table-striped">