Changeset - cb7556869244
[Not reviewed]
default
0 1 0
drewp@bigasterisk.com - 3 years ago 2022-05-31 06:18:58
drewp@bigasterisk.com
ResourceDisplay ignore more patches
1 file changed with 5 insertions and 0 deletions:
0 comments (0 inline, 0 general)
light9/web/ResourceDisplay.ts
Show inline comments
 
@@ -94,52 +94,57 @@ export class ResourceDisplay extends Lit
 
    return typeof this.uri === "string" ? new NamedNode(this.uri) : this.uri;
 
  }
 

	
 
  href() {
 
    if (!this.uri) {
 
      return "javascript:;";
 
    }
 
    return typeof this.uri === "string" ? this.uri : this.uri.value;
 
  }
 

	
 
  updated(changedProperties: PropertyValues) {
 
    if (changedProperties.has("uri")) {
 
      if (!this.graph) {
 
        return; /*too soon*/
 
      }
 
      this.runUriHandler();
 
    }
 
  }
 

	
 
  resClasses() {
 
    return this.minor ? "resource minor" : "resource";
 
  }
 

	
 
  runUriHandler() {
 

	
 
    this.graph.runHandler(this.onUri.bind(this), `rdisplay ${this.href()}` /*needs uniqueness?*/);
 
  }
 

	
 
  onUri(patch?: Patch) {
 
    if (patch && !patchContainsPreds(patch, [this.graph.Uri("rdfs:label")])) {
 
      return;
 
    }
 

	
 
    if (!this.uri) {
 
      this.label = "<no uri>";
 
      return;
 
    }
 

	
 
    const uri = this.realUri();
 
    this.graph.runHandler(this.setLabel.bind(this), `label ${uri.value}`);
 
  }
 

	
 
  setLabel(patch?: Patch) {
 
    if (patch && !patchContainsPreds(patch, [RDFS_LABEL])) {
 
      return;
 
    }
 
    const uri = this.realUri();
 
    this.label = this.graph.labelOrTail(uri);
 
  }
 

	
 
  onRename() {
 
    this.renameTo = this.label;
 
    this.shadowRoot.querySelector("#renameDialog").open();
 
    this.shadowRoot.querySelector("#renameTo").setSelectionRange(0, -1);
 
  }
 

	
 
  onRenameKey(ev) {
0 comments (0 inline, 0 general)