Skip to content

Commit

Permalink
Merge pull request #8 from kmtabish/master
Browse files Browse the repository at this point in the history
Shows dummy data when plugin load first time and it has no data
  • Loading branch information
DanielHindi committed Apr 4, 2016
2 parents ca985d5 + 48f2fce commit f872aea
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 8 deletions.
7 changes: 6 additions & 1 deletion control/content/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
ContentHome.init = function () {
ContentHome.success = function (result) {
console.info('init success result:', result);
if (result) {
if (result.data && result.id) {
ContentHome.data = result.data;
if (!ContentHome.data.content)
ContentHome.data.content = {};
Expand All @@ -30,6 +30,11 @@
}
ContentHome.googleSheetUrl = ContentHome.data.content.url;
}
else {
var dummyData = {url: "https://docs.google.com/spreadsheets/d/1DRVGSGJh5s1w2giLbizZW6t6OT1Ea-YIewzX9D4meJ4/pubhtml#gid=0"};
ContentHome.googleSheetUrl = ContentHome.data.content.url = dummyData.url;
ContentHome.mode = ContentHome.modeType.PREVIEW;
}
};
ContentHome.error = function (err) {
if (err && err.code !== STATUS_CODE.NOT_FOUND) {
Expand Down
25 changes: 18 additions & 7 deletions widget/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,28 @@
*/
WidgetHome.init = function () {
WidgetHome.success = function (result) {
if (result.data && result.id) {
WidgetHome.data = result.data;
if(WidgetHome.data && WidgetHome.data.content && WidgetHome.data.content.url) {
if (WidgetHome.data.content.mode == 'EDITABLE')
WidgetHome.data.content.url = WidgetHome.data.content.url.replace("/htmlview", "/edit");
else
WidgetHome.data.content.url = WidgetHome.data.content.url.replace("/edit", "/htmlview");
}
if (!WidgetHome.data.content)
if (WidgetHome.data && WidgetHome.data.content && WidgetHome.data.content.url) {
if (WidgetHome.data.content.mode == 'EDITABLE')
WidgetHome.data.content.url = WidgetHome.data.content.url.replace("/htmlview", "/edit");
else
WidgetHome.data.content.url = WidgetHome.data.content.url.replace("/edit", "/htmlview");
}
if (!WidgetHome.data.content)
WidgetHome.data.content = {};
console.log(">>>>>", WidgetHome.data);
}

else
{
WidgetHome.data = {
content: {}
};
var dummyData = {url: "https://docs.google.com/spreadsheets/d/1DRVGSGJh5s1w2giLbizZW6t6OT1Ea-YIewzX9D4meJ4/pubhtml#gid=0"};
WidgetHome.data.content.url = dummyData.url;
}
}
WidgetHome.error = function (err) {
if (err && err.code !== STATUS_CODE.NOT_FOUND) {
console.error('Error while getting data', err);
Expand Down

0 comments on commit f872aea

Please sign in to comment.