Skip to content

Commit

Permalink
updating documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
mehmetc committed May 5, 2017
1 parent d8a42dd commit 2885ef9
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 64 deletions.
118 changes: 71 additions & 47 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@

### This is a __pre-release__: you can help us make it better.

### Current version 0.0.5
- refactored: user, view, records, facets, ui
- added user.email
- added view.interfaceLanguage
- user, view, records, facets returns a promise
- removed Primo.explore.session.id



Watch my [EPUG-UKI AGM 2017](https://youtu.be/0IV4e94qroo?t=27m6s) presentation to get an idea of what it is and what it can do.

# Why do we need a Domain Object Model?
A domain object model according to [Tim Howard](https://www.amazon.com/Smalltalk-Developers-Guide-VisualWorks-diskette/dp/013442526X) is a logical container of domain information. You might assume that a model is present in every component and that is kind of true. When you examine a component you get a long list of context(component) specific information and there is no obvious way to access the most common(session, user, record, facet) information from within this component. And if you use an newUI service Ex Libris does not garentee that this service will still be present in the next newUI release.

I'm not saying that we need an [SDK](https://en.wikipedia.org/wiki/Software_development_kit) but we definitely need something that will withstand the test of time and maybe even is AngularJS agnostic. Currently the newUI is written using AngularJS 1 but plans are in place to upgrade to a future AngularJS and when this happens everybody who has written custom newUI code has to rewrite it for that AngularJS version.
I'm not saying that we need an [SDK](https://en.wikipedia.org/wiki/Software_development_kit) but we definitely need something that will withstand the test of time and maybe even is AngularJS agnostic. Currently the newUI is written using AngularJS 1 but plans are in place to upgrade to a future AngularJS and when this happens everybody who has written custom newUI code has to rewrite it for that AngularJS version.

TODO:write more documentation

Expand Down Expand Up @@ -42,23 +51,23 @@ angular.reloadWithDebugInfo();
//When screen is reloaded
//Get a pointer to AngularJs and angularLoad
var appInjector = angular.injector(['ng','angularLoad'])
//Get a reference to angularLoad
//Get a reference to angularLoad
var angularLoad = appInjector.get('angularLoad');
//Load the script;
angularLoad.loadScript('https://npmcdn.com/primo-explore-dom/js/primo-explore-dom.js').then(function(){
console.log('script loaded');
});

//activate explorer ui
Primo.ui.toggle();
Primo.explore.ui.toggle();

//Print the VID
Primo.explore.session.view.code
Primo.view.then(v => console.log(v.code));
```

# Quick links
- [General](#general)
- [Session](#session)
- [User](#user)
- [Components](#components)
- [Records](#records)
- [Facets](#facets)
Expand All @@ -81,54 +90,94 @@ For now it is not possible to access the $scope and $ctrl without the debug info
```js
Primo.isPrimoAvailable()
```
# Session<a name="session"></a>
## Getting the session id (only available when logged in)
## Get the library version
```js
Primo.explore.session.id
```
Primo.version
```

# User<a name="user"></a>
```Primo.user``` returns a promise

## user<a name="user"></a>
### Get user ID
```js
Primo.explore.session.user.id
Primo.user.then(user => console.log(user.id));
```
### Get user name
```js
Primo.explore.session.user.name
Primo.user.then(user => console.log(user.name));
```
### Get user email
```js
Primo.explore.session.user.email
Primo.user.then(user => console.log(user.email));
```
### Is user logged in
```js
Primo.explore.session.user.isLoggedIn()
Primo.user.then(user => console.log(user.isLoggedIn()));
```
### is user on campus
```js
Primo.explore.session.user.isOnCampus()
Primo.user.then(user => console.log(user.isOnCampus()));
```
## view<a name="view"></a>
```Primo.view``` returns a promise
### Get VID
```js
Primo.explore.session.view.code
Primo.view.then(view => console.log(view.code));
```
### Get institution code
```js
Primo.explore.session.view.institution.code
```
### Get institution name
```js
Primo.explore.session.view.institution.name
Primo.view.then(view => console.log(view.institution.name));
```
### Get interface language
```js
Primo.explore.session.view.interfaceLanguage
Primo.view.then(view => console.log(view.interfaceLanguage));
```
## ip
### Get IP address of your Primo session
```js
Primo.explore.session.ip.address
Primo.view.then(view => console.log(view.ip.address));
```

# Records<a name="records"></a>
```Primo.records``` returns a promise
This is a pointer to the new UI result set
## Getting access to all records
```js
Primo.records.then(records => console.log(records));
```
### Mapping all recordid's into a list
```js
Primo.records.then(records => console.log(records.map((m) => m.pnx.control.recordid[0])));
```
### This is just a glimpse of what can be done.

# Facets<a name="facets"></a>
```Primo.facets``` returns a promise
This is a pointer to the new UI facet set
## Getting access to all facets
```js
Primo.facets.then(facets => console.log(facets));
```
## Examining a facet
### Getting the facet name
```js
Primo.facets.then(facets => console.log(facets[0].name));
```
### Getting facet count
```js
Primo.facets.then(facets => console.log(facets[0].count));
```
### Getting facet values
```js
Primo.facets.then(facets => console.log(facets[0].values));
```
### This is just a glimpse of what can be done.

# Components<a name="Components"></a>
## Getting available components
The components list changes over time. Some components are only available in certain situations
Expand Down Expand Up @@ -170,39 +219,14 @@ The components list changes over time. Some components are only available in cer
primIcons[0].blink()
```

# Records<a name="records"></a>
## Getting access to all records
```js
Primo.explore.records
```
### Mapping all recordid's into a list
```js
Primo.explore.records.map((m) => m.pnx.control.recordid[0])
```
# Helper
__TODO:__ write documentation


# Facets<a name="facets"></a>
## Getting access to all facets
```js
Primo.explore.facets
```
## Examining a facet
### Getting the facet name
```js
Primo.explore.facets[0].name
```
### Getting facet count
```js
Primo.explore.facets[0].count
```
### Getting facet values
```js
Primo.explore.facets[0].values
```
# UI<a name="ui"></a>
TODO: Should this go into its own repo?

### Activate the UI
```js
Primo.ui.toggle()
Primo.expose.ui.toggle()
```
![PRIMO Domain Object Model UI](./img/primo-explore-dom_ui.gif "PRIMO Domain Object Model UI")
14 changes: 5 additions & 9 deletions js/custom.js
Original file line number Diff line number Diff line change
Expand Up @@ -7157,15 +7157,6 @@ var Primo = function () {
});
});
}

//Do not use will be removed. Here just for testing.
//TODO: remove

}, {
key: 'helper',
get: function get() {
return _helper2.default;
}
}]);

return Primo;
Expand Down Expand Up @@ -7226,6 +7217,11 @@ var Explore = function () {
}
return this._ui;
}
}, {
key: 'helper',
get: function get() {
return _helper2.default;
}
}]);

return Explore;
Expand Down
7 changes: 0 additions & 7 deletions js/primo.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,4 @@ export default class Primo {
});
});
}

//Do not use will be removed. Here just for testing.
//TODO: remove
static get helper(){
return Helper;
}

}
6 changes: 5 additions & 1 deletion js/primo/explore.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Ui from './explore/ui'

//this is proxy class
export default class Explore {
static get components(){
static get components() {
let c = new Components();
Helper.componentNames.forEach((selector) => {
c.add(selector);
Expand All @@ -21,4 +21,8 @@ export default class Explore {
}
return this._ui;
}

static get helper() {
return Helper;
}
}

0 comments on commit 2885ef9

Please sign in to comment.