contactsPane.js
function deleteRecursive (kb, folder) {
        return new Promise(function (resolve, reject) {
          kb.fetcher.load(folder).then(function () {
            let promises = kb.each(folder, ns.ldp('contains')).map(file => {
              if (kb.holds(file, ns.rdf('type'), ns.ldp('BasicContainer'))) {
                return deleteRecursive(kb, file)
              } else {
                console.log('deleteRecirsive file: ' + file)
                if (!confirm(' Really DELETE File ' + file)) {
                  throw new Error('User aborted delete file')
                }
                return kb.fetcher.webOperation('DELETE', file.uri)
              }
            })
            console.log('deleteRecirsive folder: ' + folder)
            if (!confirm(' Really DELETE folder ' + folder)) {
              throw new Error('User aborted delete file')
            }
            promises.push(kb.fetcher.webOperation('DELETE', folder.uri))
            Promise.all(promises).then(res => { resolve() })
          })
        })
      }
function deleteRecursive (kb, folder) {
        return new Promise(function (resolve, reject) {
          kb.fetcher.load(folder).then(function () {
            let promises = kb.each(folder, ns.ldp('contains')).map(file => {
              if (kb.holds(file, ns.rdf('type'), ns.ldp('BasicContainer'))) {
                return deleteRecursive(kb, file)
              } else {
                console.log('deleteRecirsive file: ' + file)
                if (!confirm(' Really DELETE File ' + file)) {
                  throw new Error('User aborted delete file')
                }
                return kb.fetcher.webOperation('DELETE', file.uri)
              }
            })
            console.log('deleteRecirsive folder: ' + folder)
            if (!confirm(' Really DELETE folder ' + folder)) {
              throw new Error('User aborted delete file')
            }
            promises.push(kb.fetcher.webOperation('DELETE', folder.uri))
            Promise.all(promises).then(res => { resolve() })
          })
        })
      }
function deleteRecursive ( kb , folder ) { return new Promise ( function ( resolve , reject ) { kb . fetcher . load ( folder ) . then ( function ( ) { let promises = kb . each ( folder , ns . ldp ( 'contains' ) ) . map ( file => { if ( kb . holds ( file , ns . rdf ( 'type' ) , ns . ldp ( 'BasicContainer' ) ) ) { return deleteRecursive ( kb , file ) } else { console . log ( 'deleteRecirsive file: ' + file ) if ( ! confirm ( ' Really DELETE File ' + file ) ) { throw new Error ( 'User aborted delete file' ) } return kb . fetcher . webOperation ( 'DELETE' , file . uri ) } } ) console . log ( 'deleteRecirsive folder: ' + folder ) if ( ! confirm ( ' Really DELETE folder ' + folder ) ) { throw new Error ( 'User aborted delete file' ) } promises . push ( kb . fetcher . webOperation ( 'DELETE' , folder . uri ) ) Promise . all ( promises ) . then ( res => { resolve ( ) } ) } ) } ) }
For deleting an addressbook sub-folder eg person - use with care!
For deleting an addressbook sub - folder eg person - use with care!