Skip to content

Commit

Permalink
added readonly, made attribute_service getInputAsRefType take optiona…
Browse files Browse the repository at this point in the history
…l title instead of embeddable
  • Loading branch information
ThomThomson committed Sep 2, 2020
1 parent 522019f commit e6c8e8b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
11 changes: 7 additions & 4 deletions examples/embeddable_examples/public/book/book_embeddable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,18 +95,21 @@ export class BookEmbeddable
});
}

inputIsRefType = (input: BookEmbeddableInput): input is BookByReferenceInput => {
readonly inputIsRefType = (input: BookEmbeddableInput): input is BookByReferenceInput => {
return this.attributeService.inputIsRefType(input);
};

getInputAsValueType = async (): Promise<BookByValueInput> => {
readonly getInputAsValueType = async (): Promise<BookByValueInput> => {
const input = this.attributeService.getExplicitInputFromEmbeddable(this);
return this.attributeService.getInputAsValueType(input);
};

getInputAsRefType = async (): Promise<BookByReferenceInput> => {
readonly getInputAsRefType = async (): Promise<BookByReferenceInput> => {
const input = this.attributeService.getExplicitInputFromEmbeddable(this);
return this.attributeService.getInputAsRefType(input, this, { showSaveModal: true });
return this.attributeService.getInputAsRefType(input, {
showSaveModal: true,
saveModalTitle: this.getTitle(),
});
};

public render(node: HTMLElement) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,7 @@ export class AttributeService<

getInputAsRefType = async (
input: ValType | RefType,
embeddable: IEmbeddable,
saveOptions?: { showSaveModal: boolean } | { title: string }
saveOptions?: { showSaveModal: boolean; saveModalTitle?: string } | { title: string }
): Promise<RefType> => {
if (this.inputIsRefType(input)) {
return input;
Expand Down Expand Up @@ -214,7 +213,11 @@ export class AttributeService<
<SavedObjectSaveModal
onSave={onSave}
onClose={() => reject()}
title={embeddable.getTitle() || input[ATTRIBUTE_SERVICE_KEY].title}
title={
'saveModalTitle' in saveOptions && saveOptions.saveModalTitle
? saveOptions.saveModalTitle
: input[ATTRIBUTE_SERVICE_KEY].title
}
showCopyOnSave={false}
objectType={this.type}
showDescription={false}
Expand Down

0 comments on commit e6c8e8b

Please sign in to comment.