11/* create.js UI to craete new objects in the solid-app-set world
22**
33*/
4-
5- //const SolidTls = require('solid-auth-tls')
6- const $rdf = require ( 'rdflib' )
74// const error = require('./widgets/error')
8- const widgets = require ( './widgets/index' )
5+ // const widgets = require('./widgets/index')
96// const utils = require('./utils')
107
118const UI = {
@@ -31,10 +28,10 @@ module.exports = {
3128** (suppresses asking for a full URI or workspace)
3229**
3330*/
34- function newThingUI ( context , panes ) {
31+ function newThingUI ( context , panes ) {
3532 const dom = context . dom
3633 const div = context . div
37- if ( context . me && ! context . me . uri ) throw new Error ( 'newThingUI: Invalid userid ' + me )
34+ if ( context . me && ! context . me . uri ) throw new Error ( 'newThingUI: Invalid userid: ' + context . me )
3835
3936 var iconStyle = 'padding: 0.7em; width: 2em; height: 2em;' // was: 'padding: 1em; width: 3em; height: 3em;'
4037 var star = div . appendChild ( dom . createElement ( 'img' ) )
@@ -56,33 +53,35 @@ function newThingUI(context, panes) {
5653 star . setAttribute ( 'style' , iconStyle + ( visible ? 'background-color: yellow;' : '' ) )
5754 styleTheIcons ( visible ? '' : 'display: none;' )
5855 }
59- var resetIconBar = function ( ) {
60- visibile = false
56+ /*
57+ var resetIconBar = function () {
58+ var visibile = false
6159 star.setAttribute('style', iconStyle + (visible ? 'background-color: yellow;' : ''))
6260 styleTheIcons('display: none;')
6361 }
62+ */
6463 star . addEventListener ( 'click' , selectNewTool )
6564 var makeNewAppInstance = function ( options ) {
6665 return new Promise ( function ( resolve , reject ) {
6766 var selectUI , selectUIParent
6867 var callbackWS = function ( ws , newBase ) {
6968 var newPaneOptions = {
7069 newBase : newBase ,
71- workspace : ws ,
70+ workspace : ws
7271 }
7372 for ( var opt in options ) { // get div, dom, me, folder, pane, refreshTable
7473 newPaneOptions [ opt ] = options [ opt ]
7574 }
76- console . log ( " newThingUI: Minting new " + newPaneOptions . pane . name + " at " + newPaneOptions . newBase )
75+ console . log ( ' newThingUI: Minting new ' + newPaneOptions . pane . name + ' at ' + newPaneOptions . newBase )
7776 options . pane . mintNew ( newPaneOptions )
7877 . then ( function ( newPaneOptions ) {
7978 if ( ! newPaneOptions || ! newPaneOptions . newInstance ) {
8079 throw new Error ( 'Cannot mint new - missing newInstance' )
8180 }
82- if ( newPaneOptions . folder ) {
81+ if ( newPaneOptions . folder ) {
8382 kb . add ( newPaneOptions . folder , UI . ns . ldp ( 'contains' ) , kb . sym ( newPaneOptions . newBase ) ,
8483 newPaneOptions . folder . doc ( ) ) // Ping the patch system?
85- if ( newPaneOptions . refreshTarget ) {
84+ if ( newPaneOptions . refreshTarget ) {
8685 newPaneOptions . refreshTarget . refresh ( ) // Refresh the cntaining display
8786 }
8887 selectUI . parentNode . removeChild ( selectUI )
@@ -93,8 +92,8 @@ function newThingUI(context, panes) {
9392 p . innerHTML =
9493 "Your <a target='_blank' href='" + newPaneOptions . newInstance . uri + "'><b>new " + options . noun + '</b></a> is ready to be set up. ' +
9594 "<br/><br/><a target='_blank' href='" + newPaneOptions . newInstance . uri + "'>Go to your new " + options . noun + '.</a>'
96- //selectUI.parentNode.removeChild(selectUI) // Clean up
97- selectUIParent . removeChild ( selectUI ) // Clean up
95+ // selectUI.parentNode.removeChild(selectUI) // Clean up
96+ selectUIParent . removeChild ( selectUI ) // Clean up
9897 }
9998 selectNewTool ( ) // toggle star to plain and menu vanish again
10099 } )
@@ -108,18 +107,18 @@ function newThingUI(context, panes) {
108107 options . appPathSegment = 'edu.mit.solid.pane.' + pa . name
109108 options . noun = pa . mintClass ? UI . utils . label ( pa . mintClass ) : pa . name
110109
111- if ( ! options . folder ) { // No folder given? Ask user for full URI
110+ if ( ! options . folder ) { // No folder given? Ask user for full URI
112111 selectUI = UI . authn . selectWorkspace ( dom , options , callbackWS )
113112 options . div . appendChild ( selectUI )
114113 selectUIParent = options . div
115114 } else {
116- var gotName = function ( ok , name ) {
117- if ( ! ok ) {
115+ var gotName = function ( ok , name ) {
116+ if ( ! ok ) {
118117 // selectUIParent.removeChild(selectUI) itremves itself if cancelled
119118 selectNewTool ( ) // toggle star to plain and menu vanish again
120119 } else {
121120 var uri = options . folder . uri
122- if ( ! uri . endsWith ( '/' ) ) {
121+ if ( ! uri . endsWith ( '/' ) ) {
123122 uri = uri + '/'
124123 }
125124 uri = uri + encodeURIComponent ( name ) + '/'
@@ -129,7 +128,6 @@ function newThingUI(context, panes) {
129128 selectUI = getNameForm ( dom , UI . store , options . noun , gotName )
130129 options . div . appendChild ( selectUI )
131130 selectUIParent = options . div
132-
133131 }
134132 } )
135133 } // makeNewAppInstance
@@ -190,7 +188,7 @@ function newThingUI(context, panes) {
190188//
191189// Used in contacts for new groups, individuals.
192190//
193- function getNameForm ( dom , kb , classLabel , gotNameCallback ) {
191+ function getNameForm ( dom , kb , classLabel , gotNameCallback ) {
194192 var form = dom . createElement ( 'div' ) // form is broken as HTML behaviour can resurface on js error
195193 form . innerHTML = '<p>Name of new ' + classLabel + ':</p>'
196194 var namefield = dom . createElement ( 'input' )
@@ -213,7 +211,7 @@ function getNameForm(dom, kb, classLabel, gotNameCallback) {
213211 } , false )
214212 form . appendChild ( namefield )
215213
216- var br = form . appendChild ( dom . createElement ( 'br' ) )
214+ form . appendChild ( dom . createElement ( 'br' ) )
217215
218216 var cancel = form . appendChild ( dom . createElement ( 'button' ) )
219217 cancel . setAttribute ( 'type' , 'button' )
0 commit comments