Document Manager is a backend-oriented component and expects data loaded by the URL:
view:"docmanager", url:"remote/data"
Document Manager expects a JSON array, where each element (data item) contains the following fields:
Document Manager expects JSON data where each array element (folder) contains the following fields:
Document Manager inherits all public services of File Manager and has several of its own:
1. Local Data
// update the file data on the client side
const data = {
value:"myadventures.txt",
date: new Date(),
size:1231,
id:"/myadventures.txt",
type:"code"
};
$$("docs").getService("local").updateFile(data.id, {
size: data.size, date: data.date
});
2. LocalUsers
$$("dm").getService("localusers")
.users()
.then(users => {/* Data collection */});
3. LocalTags
$$("dm").getService("localtags")
.tags() // access to tags data collection
.then(t => {
// t is a DataCollection with all tags
const tags = t.serialize(); // an array with tags
});
4. Operations
// open a file in a new browser tab
const file = {
value:"pixeljuice.pdf",
date: new Date(),
size:7231,
id:"/pixeljuice.pdf",
type:"document"
};
$$("docs").getService("operations").open(file);
These services work with the backend server:
5. Backend
const back = $$("dm").getService("backend");
back.folders(id).then((data) => console.log(data));
6. Users
Provides methods for issuing requests to the backend for:
const users = $$("dm").getService("users");
users.comments(commentID); // retrieving file comments
7. Tags
Provides methods for issuing requests to the backend for:
const tags = $$("dm").getService("tags");
tags.removeTag(id) // removes a specified tag from the server
8. Versions
Provides methods for issuing requests to the backend for:
const versions = $$("dm").getService("versions");
versions.versions(id); // getting version history of a specified file
Study the models folder in the source code for method signatures.
All data operations of File Manager are applicable to Document Manager. It also has its own API.
The contents of group folders are stored in DataCollections. Each collection is accessible via its source. To get the current source, call the getState method:
const source = $$("dm").getState().source;
To get files from a group folder, call the files() method of LocalData with the following parameters:
const source = $$("dm").getState().source;
const data = $$("dm").getService("local")
.files("/", true, source);
If you're not sure whether the directory is loaded, you can request files asynchronously:
const data = $$("dm").getService("local")
.files("/", false, source)
.then(files => {
/* files is a data collection */
});
All users are stored in a DataCollection. To get the collection, call the users() method of the LocalUsers service. The method can take the only parameter:
$$("dm").getService("localusers")
.users()
.then(users => {/* Data collection */});
All tags are stored in a DataCollection. To get the collection, call the tags() method of the LocalTags service. The method can take the only parameter:
$$("dm").getService("localtags")
.tags() // access to tags data collection
.then(t => {
const tags = t.serialize(); // an array with tags
});
Document Manager supports all operations available for File Manager.
You can remove all elements from the currently opened group folder by calling the clearAll() method of its collection:
const data = $$("dm").getService("local");
const path = $$("dm").getState().source;
data.files("/", false, source).then(collection =>
collection.clearAll());
You can also clear users and tags local collections:
data.users().then(collection => collection.clearAll());
data.tags().then(collection => collection.clearAll());
Document Manager supports all operations available for File Manager.
To refresh contents of a group folder, call refresh() of LocalData:
const data = $$("dm").getService("local");
const source = $$("dm").getState().source;
data.refresh("/", source);
You can reload users and tags by calling the users() and tags() methods of the Local Service and passing the argument true to the methods:
const data = $$("dm").getService("local");
data.users(true);
data.tags(true);
Back to top