app/assets/javascripts/pageflow/internal_links/editor/models/page_link.js in pageflow-internal-links-0.2.0 vs app/assets/javascripts/pageflow/internal_links/editor/models/page_link.js in pageflow-internal-links-1.0.0
- old
+ new
@@ -1,16 +1,33 @@
pageflow.internalLinks.PageLink = Backbone.Model.extend({
i18nKey: 'pageflow/internal_links/page_link',
+ mixins: [pageflow.transientReferences],
+
targetPage: function() {
return pageflow.pages.getByPermaId(this.get('target_page_id'));
},
label: function() {
return this.get('label');
},
+ thumbnailFile: function() {
+ var thumbnailFile = this.getReference('thumbnail_image_id',
+ pageflow.imageFiles);
+
+ if (thumbnailFile) {
+ return thumbnailFile;
+ }
+ else if (this.targetPage()) {
+ return this.targetPage().thumbnailFile();
+ }
+ else {
+ return null
+ }
+ },
+
editPath: function() {
return '/internal_links_pages/' + this.getRoutableId() + '/page_links/' + this.id;
},
getRoutableId: function() {
@@ -30,6 +47,6 @@
},
remove: function() {
this.collection.remove(this);
}
-});
\ No newline at end of file
+});