Skip to content

Commit

Permalink
Merge branch 'develop' into survey_menu
Browse files Browse the repository at this point in the history
  • Loading branch information
Angamanga authored May 11, 2021
2 parents dfd49b0 + abd2f04 commit 41b5826
Show file tree
Hide file tree
Showing 52 changed files with 951 additions and 147 deletions.
10 changes: 10 additions & 0 deletions app/common/controllers/page-metadata.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ function (
$scope.pageDescription = null;
$scope.pageKeywords = null;
$scope.pageRobots = null;
$scope.paymentPoiner = null;

$scope.appStoreId = $window.ushahidi.appStoreId;

Expand All @@ -34,6 +35,7 @@ function (
$rootScope.$on('event:update:header', function () {
$scope.reloadSiteConfig();
});

$scope.reloadSiteConfig();

$rootScope.$on('setPageTitle', function (event, title) {
Expand Down Expand Up @@ -73,4 +75,12 @@ function (
}
}
});

$rootScope.$on('setPaymentPointer', function (event, pointer) {
$scope.paymentPoiner = null;

if (pointer && pointer.length) {
$scope.paymentPointer = pointer;
}
});
}];
5 changes: 5 additions & 0 deletions app/common/directives/file-upload.directive.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ function FileUpload() {
$scope, $attrs, Notify
) {
$scope.required = typeof $attrs.required !== 'undefined';

$scope.$on('event:FileUpload', function (event) {
angular.element(document.querySelector('#file')).val('');
});

$scope.uploadFile = function ($event) {
if (validateFile($event.target.files[0])) {
$scope.container.file = $event.target.files[0];
Expand Down
20 changes: 19 additions & 1 deletion app/common/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
"title" : "Documentation",
"description" : "Learn how to set up, configure, and manage your Ushahidi deployment."
},
"donate": "Donate",
"donation": "Donation",
"intercom": {
"intercom" : "Intercom",
"description" : "Contact Ushahidi staff for chat support"
Expand Down Expand Up @@ -1039,7 +1041,9 @@
"webhooks" : "Webhooks",
"webhooks_desc" : "Create webhooks that send Ushahidi Platform data to external applications when specific events are triggered.",
"plans" : "Plans",
"plan_desc" : "Your deployment's current plan is <strong>{{current_plan}}</strong>."
"plan_desc" : "Your deployment's current plan is <strong>{{current_plan}}</strong>.",
"donation": "Donation",
"donation_desc": "Create and manage the donations people can make towards your organisation."
},
"user_settings": {
"user_settings_desc_1": "Here you can add your unique API key for your Humanitarian Data Exchange (HDX) account.",
Expand Down Expand Up @@ -1153,6 +1157,16 @@
"search_terms_desc": "Add search terms separated with commas"
}
},
"donation": {
"title" : {
"label": "Donation title",
"placeholder": "Enter the title of your donation",
"required": "Donation title is required"
},
"wallet": {
"required": "Donation wallet address is required"
}
},
"roles" :{
"member": "Member",
"admin": "Admin",
Expand Down Expand Up @@ -1455,6 +1469,10 @@
"general_settings" : {
"save_success" : "General settings saved"
},
"donation_settings": {
"save_success" : "Donation settings saved",
"delete_question": "Are you sure you want to delete this {{name}}."
},
"map_settings" : {
"save_success" : "Map settings saved"
},
Expand Down
14 changes: 13 additions & 1 deletion app/common/services/endpoints/sdk/SurveysSdk.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,5 +109,17 @@ function (
.deleteSurvey(id);
}

return { findSurveyTo, getSurveysTo, findSurvey, getSurveys, saveSurvey, deleteSurvey };
const areOptionsUnique = function (options) {
return ushahidi().areOptionsUnique(options);
}

const fieldHasTranslations = function (field, language) {
return ushahidi().fieldHasTranslations(field, language);
}

const fieldCanHaveOptions = function (field) {
return ushahidi().fieldCanHaveOptions(field);
}

return { findSurveyTo, getSurveysTo, findSurvey, getSurveys, saveSurvey, deleteSurvey, areOptionsUnique, fieldHasTranslations, fieldCanHaveOptions };
}];
2 changes: 2 additions & 0 deletions app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

<meta name="apple-itunes-app" content="app-id={{appStoreId}}, app-argument={{currentFullUrl}}>">

<meta name="monetization" ng-attr-content="{{paymentPointer}}">

<link rel="manifest" href="/manifest.json">

<base href="/">
Expand Down
4 changes: 4 additions & 0 deletions app/main/activity/activity.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ <h1 class="mode-context-title"><a href="/" ng-bind="nav.site.name"></a></h1>

<main role="main">
<div class="toolbar" ng-show="isActivityAvailable" >
<div class="button-group">
<donation></donation>
</div>

<form role="search" class="searchbar" name="searchForm" ng-submit="saveFilters()">

<div class="searchbar-options">
Expand Down
33 changes: 33 additions & 0 deletions app/main/donation/donation-button.directive.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
module.exports = DonationButtonDirective;

DonationButtonDirective.$inject = [];
function DonationButtonDirective() {
return {
restrict: 'E',
replace: true,
scope: {
button: '=?'
},
controller: DonationButtonController,
template: require('./donation-button.html')
};
}

DonationButtonController.$inject = [
'$scope',
'$window',
'DonationService'
];
function DonationButtonController(
$scope,
$window,
DonationService
) {
$scope.loading = false;
$scope.openDonationModal = DonationService.openDonationModal;
$scope.isButton = isButton;

function isButton() {
return $scope.button;
}
}
11 changes: 11 additions & 0 deletions app/main/donation/donation-button.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<button type="button" class="button button-alpha button-plain" data-modal="donate" ng-click="openDonationModal()">
<div class="loading" ng-if="loading">
<div class="line"></div>
<div class="line"></div>
<div class="line"></div>
</div>
<svg class="iconic" role="img" ng-hide="loading">
<use xlink:href="/img/iconic-sprite.svg#heart"></use>
</svg>
<span translate="app.donate">Donate</span>
</button>
26 changes: 26 additions & 0 deletions app/main/donation/donation-modal.directive.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
const { config } = require('raven-js');

module.exports = DonationModalDirective;

DonationModalDirective.$inject = [];
function DonationModalDirective() {
return {
restrict: 'E',
scope: {},
replace: true,
controller: DonationModalController,
template: require('./donation-modal.html')
};
}

DonationModalController.$inject = [
'$scope',
'$rootScope'
];
function DonationModalController(
$scope,
$rootScope
) {
$scope.donation = $rootScope.donation;
$scope.donationClientEnabled = $rootScope.donationClientEnabled;
}
29 changes: 29 additions & 0 deletions app/main/donation/donation-modal.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<div class="modal-body">
<!-- <h3 class="modal-title">{{ donation.title }}</h3> -->

<p> {{ donation.description }} </p>

<div class="modal-images">
<img ng-repeat="image in donation.images" ng-src="{{ image.original_file_url }}">
</div>

<div class="divider"></div>

<p class="soft-text" ng-show="donationClientEnabled">
<svg class="iconic">
<use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="/img/iconic-sprite.svg#heart"></use>
</svg>
Web monetization is enabled on this website.
Thank you for your donation. You have donated {{ donation.assetCode }} {{ donation.formattedAmount }} so far
</p>

<p class="soft-text" ng-show="!donationClientEnabled">
Ushahidi deployments are now web monetization enabled.
Web monetization is a way of supporting the websites you love without playing advertisers game.
All you need is to get your browser setup. Click the link below to learn how you can donate.
</p>

<div ng-show="!donationClientEnabled">
<a target="_blank" href="https://docs.ushahidi.com/ushahidi-platform-user-manual/7.-managing-your-donations/7.1-donations#7-1-3-how-to-support-deployments-with-donations" class="link-blue">How can I donate?</a>
</div>
</div>
11 changes: 11 additions & 0 deletions app/main/donation/donation-module.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
angular.module('ushahidi.donation', [])

.directive('donation', require('./donation.directive.js'))

.directive('donationButton', require('./donation-button.directive.js'))

.directive('donationModal', require('./donation-modal.directive.js'))

.directive('donationToolbar', require('./donation-toolbar.directive.js'))

.service('DonationService', require('./donation.service.js'));
31 changes: 31 additions & 0 deletions app/main/donation/donation-toolbar.directive.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
module.exports = DonationToolbarDirective;

DonationToolbarDirective.$inject = [];
function DonationToolbarDirective() {
return {
restrict: 'E',
scope: {},
replace: true,
controller: DonationToolbarController,
template: require('./donation-toolbar.html')
};
}

DonationToolbarController.$inject = [
'$scope',
'$rootScope',
'DonationService'
];
function DonationToolbarController(
$scope,
$rootScope,
DonationService
) {
$scope.formattedAmount = 0.00;
$scope.openDonationModal = DonationService.openDonationModal;

$rootScope.$on('setDonatedAmount', function (event, value) {
$scope.formattedAmount = value;
$scope.$apply();
});
}
15 changes: 15 additions & 0 deletions app/main/donation/donation-toolbar.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<button class="button button-transparent" data-modal="donation" ng-click="openDonationModal()">
<span class="toolbar-donating">
<span class="iconic">
<svg role="img" class="coins iconic">
<use xlink:href="/img/iconic-sprite.svg#coins"></use>
</svg>
</span>
<span class="button-label">{{ formattedAmount }}</span>
<span class="iconic">
<svg role="img" class="iconic">
<use xlink:href="/img/iconic-sprite.svg#info-circle"></use>
</svg>
</span>
</span>
</button>
61 changes: 61 additions & 0 deletions app/main/donation/donation.directive.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
module.exports = DonationDirective;

DonationDirective.$inject = [];
function DonationDirective() {
return {
restrict: 'E',
replace: true,
scope: {},
controller: DonationController,
template: require('./donation.html')
};
}

DonationController.$inject = [
'$scope',
'$rootScope',
'ConfigEndpoint',
'DonationService',
'Features'
];
function DonationController(
$scope,
$rootScope,
ConfigEndpoint,
DonationService,
Features
) {
$scope.loading = true;
$scope.donationClientEnabled = $rootScope.donationClientEnabled || false;
$scope.donationDeploymentEnabled = false;
$scope.donationFeatureEnabled = false;

$rootScope.$on('event:donation:started', function (event) {
$rootScope.donationClientEnabled = true;
$scope.donationClientEnabled = true;
});

$rootScope.$on('event:donation:settings:update', function (event, value) {
$rootScope.donation = value;
});

Features.loadFeatures().then(function () {
ConfigEndpoint.get({id: 'site'}).$promise.then(function (site) {
$rootScope.donation = site.donation;
$scope.donationDeploymentEnabled = site.donation.enabled;
$scope.donationFeatureEnabled = Features.isFeatureEnabled('donation');

console.log($scope.donationClientEnabled);
console.log($scope.donationFeatureEnabled);
console.log($scope.donationDeploymentEnabled);

if ($scope.donationFeatureEnabled && $scope.donationDeploymentEnabled) {
$rootScope.$emit('setPaymentPointer', $rootScope.donation.wallet);

DonationService.setupMonetization();
}

$scope.loading = false;
});
});
}
5 changes: 5 additions & 0 deletions app/main/donation/donation.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<span ng-show="donationFeatureEnabled && donationDeploymentEnabled">
<donation-button ng-show="!donationClientEnabled"> </donation-button>
<donation-toolbar ng-show="donationClientEnabled"> </donation-toolbar>
</span>

Loading

0 comments on commit 41b5826

Please sign in to comment.