Skip to content

Commit e16a731

Browse files
committed
Merge pull request #9 from sakshityagi/master
Pull request after bug fixing
2 parents d9d0d74 + f2eefed commit e16a731

File tree

11 files changed

+187
-146
lines changed

11 files changed

+187
-146
lines changed

README.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,7 @@
1-
# smoochChatPlugin
2-
integration with Smooch.io
1+
# Smooch Chat Plugin ![](https://api.travis-ci.org/BuildFire/smoochChatPlugin.svg)
2+
3+
BuildFire plugin for integration with Smooch.io.
4+
5+
### How to run test cases(For plugin)
6+
- npm install
7+
- karma start

control/design/app.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,12 @@
5757
DesignHome.success = function (result) {
5858
console.info('Saved data result: ', result);
5959
DesignHome.saveDataCompletion = false;
60+
Buildfire.messaging.sendMessageToWidget({'name': STATUS_CODE.UPDATED, 'data': result.data});
6061
};
6162
DesignHome.error = function (err) {
6263
console.error('Error while saving data : ', err);
6364
DesignHome.saveDataCompletion = false;
6465
};
65-
Buildfire.messaging.sendMessageToWidget({'name': STATUS_CODE.UPDATED, 'color': DesignHome.data.design.color});
6666
DataStore.save(newObj, tag).then(DesignHome.success, DesignHome.error);
6767
};
6868

control/settings/app.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
// }
1919
//});
2020

21-
SettingsHome.data = {
21+
var _data = {
2222
settings: {
2323
"apiKey": "",
2424
"headerText": ""
@@ -33,14 +33,18 @@
3333
SettingsHome.masterData = angular.copy(data);
3434
};
3535

36+
SettingsHome.getAPIKeyStatus = function () {
37+
return SettingsHome.data && SettingsHome.data.settings && SettingsHome.data.settings.apiKey ? "true" : 'Please enter Smooch Chat API Key';
38+
};
39+
3640
/*Init method call, it will bring all the pre saved data*/
3741
SettingsHome.init = function () {
3842
SettingsHome.success = function (result) {
3943
console.info('init success result:', result);
4044
if (result) {
4145
SettingsHome.data = result.data;
4246
if (!SettingsHome.data.settings)
43-
SettingsHome.data.settings = {};
47+
SettingsHome.data.settings = {"apiKey": "", "headerText": ""};
4448
SettingsHome.updateMasterItem(SettingsHome.data);
4549
}
4650
};
@@ -49,6 +53,11 @@
4953
console.error('Error while getting data', err);
5054
}
5155
else if (err && err.code === STATUS_CODE.NOT_FOUND) {
56+
if(!SettingsHome.data) {
57+
SettingsHome.data = angular.copy(_data);
58+
} else if(SettingsHome.data && !SettingsHome.data.settings) {
59+
SettingsHome.data.settings = {"apiKey": "", "headerText": ""};
60+
}
5261
SettingsHome.saveData(JSON.parse(angular.toJson(SettingsHome.data)), TAG_NAMES.SMOOCH_CHAT_INFO);
5362
}
5463
};
@@ -62,6 +71,7 @@
6271
}
6372
SettingsHome.success = function (result) {
6473
console.info('Saved data result: ', result);
74+
Buildfire.messaging.sendMessageToWidget({'name': STATUS_CODE.SETTINGS_UPDATED, 'data': result.data});
6575
};
6676
SettingsHome.error = function (err) {
6777
console.error('Error while saving data : ', err);

control/settings/enums.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
.constant('STATUS_CODE', {
99
INSERTED: 'inserted',
1010
UPDATED: 'updated',
11+
SETTINGS_UPDATED: 'SETTINGS_UPDATED',
1112
NOT_FOUND: 'NOTFOUND',
1213
UNDEFINED_DATA: 'UNDEFINED_DATA',
1314
UNDEFINED_OPTIONS: 'UNDEFINED_OPTIONS',

control/settings/index.html

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,7 @@
2828
<div ng-controller="SettingsHomeCtrl as SettingsHome">
2929
<div class="item clearfix row" ng-if="SettingsHome.data">
3030
<div class="main pull-right col-md-9">
31-
<div class="alert alert-danger alert-sm text-center"
32-
ng-if="!SettingsHome.data.settings.apiKey">Please enter Smooch Chat API Key
31+
<div class="alert alert-danger alert-sm text-center" ng-if="SettingsHome.getAPIKeyStatus() != 'true'">{{SettingsHome.getAPIKeyStatus()}}
3332
</div>
3433
</div>
3534
</div>

test/widget/app.spec.js

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -83,15 +83,6 @@ describe('Unit: smoochChatPluginWidget app', function () {
8383
};
8484
WidgetHome.error(err);
8585
});
86-
it('it should pass if WidgetHome.onUpdateCallback is called', function () {
87-
var event = {
88-
tag: TAG_NAMES.SMOOCH_CHAT_INFO
89-
};
90-
WidgetHome.data = {
91-
design: ""
92-
};
93-
WidgetHome.onUpdateCallback(event);
94-
});
9586
});
9687
});
9788
});

0 commit comments

Comments
 (0)