mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-06 22:40:14 -05:00
Updated save button handling for links
refs https://github.com/TryGhost/Team/issues/2116
This commit is contained in:
parent
9e3e3d7131
commit
910d13fbab
3 changed files with 24 additions and 2 deletions
|
@ -50,7 +50,7 @@
|
|||
{{else}}
|
||||
<GhTaskButton
|
||||
@buttonText="Update"
|
||||
@task={{this.setLink}}
|
||||
@task={{this.updateLinks}}
|
||||
@successText="Link updated"
|
||||
@class="gh-btn gh-btn-green gh-btn-icon" />
|
||||
{{/if}}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import Component from '@glimmer/component';
|
||||
import {action} from '@ember/object';
|
||||
import {task} from 'ember-concurrency';
|
||||
import {tracked} from '@glimmer/tracking';
|
||||
|
||||
const PAGE_SIZE = 5;
|
||||
|
@ -49,6 +50,25 @@ export default class LinksTable extends Component {
|
|||
}
|
||||
}
|
||||
|
||||
@task
|
||||
*updateLinks() {
|
||||
try {
|
||||
const newUrl = new URL(event.target.value);
|
||||
const linkObj = this.links.find((_link) => {
|
||||
return _link.link.link_id === this.editingLink;
|
||||
});
|
||||
// Only call update if the new link is different from current link
|
||||
if (linkObj.link.to !== newUrl.href) {
|
||||
yield this.args.updateLinkTask.perform(this.editingLink, newUrl.href);
|
||||
}
|
||||
this.editingLink = null;
|
||||
this.showError = null;
|
||||
return true;
|
||||
} catch (e) {
|
||||
this.showError = this.editingLink;
|
||||
}
|
||||
}
|
||||
|
||||
get links() {
|
||||
return this.args.links;
|
||||
}
|
||||
|
|
|
@ -98,7 +98,9 @@
|
|||
{{!-- Empty state --}}
|
||||
{{else}}
|
||||
<Posts::LinksTable
|
||||
@links={{this.links}} @updateLink={{this.updateLink}}
|
||||
@links={{this.links}}
|
||||
@updateLink={{this.updateLink}}
|
||||
@updateLinkTask={{this._updateLinks}}
|
||||
@showSuccess={{this.showSuccess}}
|
||||
/>
|
||||
{{/if}}
|
||||
|
|
Loading…
Reference in a new issue