changeset 2862:b8795a6452f8

#94
author Nicholas Jillings <nicholas.jillings@mail.bcu.ac.uk>
date Thu, 27 Apr 2017 13:06:29 +0100
parents 79258b2a8245
children 7b1c05a9514a
files test_create.html test_create/test_core.js
diffstat 2 files changed, 13 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/test_create.html	Thu Apr 27 12:57:31 2017 +0100
+++ b/test_create.html	Thu Apr 27 13:06:29 2017 +0100
@@ -424,6 +424,7 @@
         </div>
         <div class="node pageNode" ng-controller="page" ng-repeat="page in specification.pages">
             <h2>Page</h2>
+            <button type="button" class="btn btn-danger" ng-click="removePage(page)">Remove Page</button>
             <div class="attributes">
                 <div class="attribute">
                     <span>Unique ID: </span>
--- a/test_create/test_core.js	Thu Apr 27 12:57:31 2017 +0100
+++ b/test_create/test_core.js	Thu Apr 27 13:06:29 2017 +0100
@@ -1,4 +1,4 @@
-/* globals document, angular, window, Promise, XMLHttpRequest, Specification, XMLSerializer, Blob, DOMParser*/
+/* globals document, angular, window, Promise, XMLHttpRequest, Specification, XMLSerializer, Blob, DOMParser, FileReader*/
 function get(url) {
     // Return a new promise.
     return new Promise(function (resolve, reject) {
@@ -64,6 +64,16 @@
         $s.specification.createNewPage();
     };
 
+    $s.removePage = function (page) {
+        var index = $s.specification.pages.findIndex(function (a) {
+            return a == page;
+        });
+        if (index === -1) {
+            throw ("Invalid Page");
+        }
+        $s.specification.pages.splice(index, 1);
+    };
+
     $s.exportXML = function () {
         var s = new XMLSerializer();
         var doc = specification.encode();
@@ -130,7 +140,7 @@
             var p = new DOMParser();
             specification.decode(p.parseFromString(r.result, "text/xml"));
             $s.$apply();
-        }
+        };
         r.readAsText($s.file);
     };
 }]);