Skip to content

Commit

Permalink
feat(pb-authority-lookup): custom connector can now have an edit butt…
Browse files Browse the repository at this point in the history
…on (used by future versions of annotation tool)
  • Loading branch information
wolfgangmm committed Oct 24, 2023
1 parent fdd1699 commit 1240172
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 9 deletions.
5 changes: 5 additions & 0 deletions src/authority/custom.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export class Custom extends Registry {

constructor(endpoint, configElem) {
super(configElem);
this._editable = configElem.hasAttribute('edit');
this._endpoint = endpoint;
this._connectors = createConnectors(endpoint, configElem);
this._connectors.forEach((connector) => {
Expand All @@ -18,6 +19,10 @@ export class Custom extends Registry {
);
}

get editable() {
return this._editable;
}

async query(key) {
return new Promise(resolve => {
fetch(
Expand Down
4 changes: 4 additions & 0 deletions src/authority/registry.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ export class Registry {
this._register = name;
}

get editable() {
return false;
}

/**
* Query the authority and return a RegistryResult.
*
Expand Down
20 changes: 11 additions & 9 deletions src/pb-authority-lookup.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ export class PbAuthorityLookup extends pbMixin(LitElement) {
return Promise.resolve();
}
const authority = this._authorities[register];
console.log('<pb-authority-lookup> Retrieving info for %s from %s', id, register);
console.log('<pb-authority-lookup> Retrieving info for %s from %s using %s', id, register, authority.name);
let info = await authority.info(id, container);
if (info.strings) {
info = Object.assign(info, {
Expand Down Expand Up @@ -131,14 +131,16 @@ export class PbAuthorityLookup extends pbMixin(LitElement) {
${item.provider ? html`<div><span class="source" part="source">${item.provider}</span></div>` :null}
<div><span class="register" part="register">${item.register}</span></div>
<div class="icons">
<paper-icon-button
icon="editor:mode-edit"
@click="${() => this._select(item)}"
></paper-icon-button>
</div>
${item.details ? html`<div class="details" part="details">${item.details}</div>` : null}
${
this._authorities[this.type].editable ?
html`<div class="icons">
<paper-icon-button
icon="editor:mode-edit"
@click="${() => this._select(item)}"
></paper-icon-button>
</div>` : null
}
${item.details ? html`<div class="details" part="details">${item.details}</div>` : null}
</li>
`;
Expand Down

0 comments on commit 1240172

Please sign in to comment.