Skip to content

Commit

Permalink
Merge pull request #392 from ushahidi/develop
Browse files Browse the repository at this point in the history
Release v3.6.1
  • Loading branch information
willdoran authored Oct 28, 2016
2 parents 0e78270 + f9b3186 commit 533401f
Show file tree
Hide file tree
Showing 82 changed files with 978 additions and 294 deletions.
5 changes: 3 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ notifications:
# sauce_connect: true
language: node_js
matrix:
allow_failures:
- node_js: stable
include:
# Run everything with v5 (match production)
# Skip e2e test during mustang build
Expand All @@ -23,8 +25,7 @@ matrix:
env: TEST_SUITE=lint
- node_js: 5
env: TEST_SUITE=unit
# Run unit test with 0.12 and current stable too
- node_js: 0.12
- node_js: 6
env: TEST_SUITE=unit
- node_js: stable
env: TEST_SUITE=unit
Expand Down
2 changes: 2 additions & 0 deletions app/common/common-module.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ angular.module('ushahidi.common', [
.directive('ushModalContainer', require('./directives/modal-container.directive.js'))
.directive('modalBody', require('./directives/modal-body.directive.js'))
.directive('layoutClass', require('./directives/layout-class.directive.js'))
.directive('embedOnly', require('./directives/embed-only.directive.js'))
.directive('ushLogo', require('./directives/ush-logo.directive.js'))

.directive('filterSearchbar', require('./directives/filter-system/filter-searchbar.js'))
.directive('filterRole', require('./directives/filter-system/filter-role.js'))
Expand Down
5 changes: 3 additions & 2 deletions app/common/controllers/intercom.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ function (
$window
) {
var pattern = /^(?:https?:\/\/)?(?:[^@\/\n]+@)?(?:www\.)?([^:\/\n]+)/g;

$rootScope.$on('event:authentication:login:succeeded', function () {
$scope.startIntercom();
if ($window.self === $window.top) {
$scope.startIntercom();
}
});

$scope.startIntercom = function () {
Expand Down
1 change: 1 addition & 0 deletions app/common/controllers/navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ function NavigationController(Authentication, ConfigEndpoint, BootstrapConfig, $
$rootScope.$on('event:update:header', reloadSiteConfig);

function activate() {

Features.loadFeatures().then(function () {
vm.activityIsAvailable = Features.isViewEnabled('activity');
vm.planIsAvailable = Features.isViewEnabled('plan');
Expand Down
20 changes: 20 additions & 0 deletions app/common/directives/embed-only.directive.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
module.exports = EmbedOnlyDirective;

EmbedOnlyDirective.$inject = [];
function EmbedOnlyDirective() {
return {
restrict: 'A',
controller: EmbedOnlyController
};
}

EmbedOnlyController.$inject = ['$scope', '$element', '$attrs', '$rootScope', '_', '$window'];
function EmbedOnlyController($scope, $element, $attrs, $rootScope, _, $window) {
var globalEmbed = ($window.self !== $window.top) ? true : false;

if (globalEmbed && ($attrs.embedOnly === 'false')) {
$element.addClass('hidden');
} else if (!globalEmbed && ($attrs.embedOnly === 'true')) {
$element.addClass('hidden');
}
}
15 changes: 12 additions & 3 deletions app/common/directives/file-upload.directive.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,27 @@ function FileUpload() {
return {
restrict: 'E',
templateUrl: 'templates/common/directives/file-upload.html',
replace: true,
scope: {
fileContainer: '='
container: '='
},

controller: [
'$scope', '$attrs',
function (
$scope, $attrs
) {
$scope.required = typeof $attrs.required !== 'undefined';
$scope.uploadFile = function ($event) {
$scope.fileContainer.file = $event.target.files[0];
$scope.container.file = $event.target.files[0];
var reader = new FileReader();
reader.onload = function () {
var dataURL = reader.result;
$scope.container.dataURI = dataURL;
$scope.container.changed = true;
$scope.$apply();
};
reader.readAsDataURL($event.target.files[0]);

};
}]
};
Expand Down
3 changes: 1 addition & 2 deletions app/common/directives/file-upload.html
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
<input id="appearance-header-image" name="file" type="file" custom-on-change='uploadFile' ng-required="{{ required }}" />

<input name="file" type="file" custom-on-change='uploadFile' ng-required="{{ required }}" />
2 changes: 1 addition & 1 deletion app/common/directives/first-time-config.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ <h1 translate>settings.customize_your_new_deployment</h1>

<label class="input-label" for="appearance-header-image" translate>settings.appearance_header_image</label>
<p class="small" translate>settings.appearance_header_image_instructions</p>
<file-upload file-container="fileContainer">
<file-upload container="fileContainer">
</file-upload>

<div class="divider white"></div>
Expand Down
18 changes: 15 additions & 3 deletions app/common/directives/layout-class.directive.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,19 @@ function LayoutClassDirective() {
};
}

LayoutClassController.$inject = ['$scope', '$rootScope'];
function LayoutClassController($scope, $rootScope) {
$rootScope.setLayout('layout-' + $scope.layout);
LayoutClassController.$inject = ['$scope', '$rootScope', '$window', 'Util'];
function LayoutClassController($scope, $rootScope, $window, Util) {
var isEmbed = ($window.self !== $window.top) ? true : false;
// In the case of map we omit the layout-a class
var isMap = (Util.currentUrl()) ? Util.currentUrl().indexOf('map') > 0 : false;

if (!isEmbed) {
$rootScope.setLayout('layout-' + $scope.layout);
} else if (isEmbed && isMap) {
$rootScope.setLayout('layout-embed');
} else {
// If we are in embed mode
// we must append the layout to the embed layout
$rootScope.setLayout('layout-embed layout-' + $scope.layout);
}
}
15 changes: 15 additions & 0 deletions app/common/directives/ush-logo.directive.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
module.exports = UshLogoDirective;

UshLogoDirective.$inject = [];
function UshLogoDirective() {
return {
restrict: 'E',
controller: UshLogoController,
replace: true,
templateUrl: 'templates/common/directives/ush-logo.html'
};
}

UshLogoController.$inject = [];
function UshLogoController() {
}
4 changes: 4 additions & 0 deletions app/common/directives/ush-logo.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<a embed-only=true href="https://www.ushahidi.com" class="ushahidi-bug" target="_blank">
<ng-include include-replace src="'templates/common/directives/mode-bar/ushahidi-logo.html'"></ng-include>
<span class="hidden">Powered by Ushahidi</span>
</a>
1 change: 0 additions & 1 deletion app/common/global/event-handlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ function (
$rootScope.setLayout = function (layout) {
$rootScope.globalLayout = layout;
};

// Setup PL modal visible and switching function
$rootScope.modalVisible = false;
$rootScope.toggleModalVisible = function (state) {
Expand Down
11 changes: 11 additions & 0 deletions app/common/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@
"powered_by_ushahidi" : "Powered by Ushahidi.",
"support" : "Ushahidi Support",
"by" : "by",
"submit" : "Submit",
"submit_another" : "Submit & Add Another",
"can_see_this" : "can see this",
"collections" : "Collections",
"create_collection" : "Create collection",
"export_to_csv" : "Export to CSV",
"create_new" : "Create new",
"created_by" : "Created by {{author}}",
"documentation": {
Expand Down Expand Up @@ -59,6 +62,7 @@
"apply_filters" : "Apply filters",
"show_more_less" : "Show more/less",
"filters" : "Filters",
"filter_by_survey" : "Filter by survey",
"configure" : "Configure",
"post" : "Post",
"name" : "Name",
Expand Down Expand Up @@ -248,6 +252,8 @@
"q": "Keyword",
"created_after": "Start date",
"created_before": "End date",
"date_after": "Start date",
"date_before": "End date",
"center_point": "Location",
"tags": "Category",
"form": "Survey",
Expand Down Expand Up @@ -692,6 +698,9 @@
"continue" : "Continue",
"current_header" : "Current background image",
"customize_your_new_deployment" : "Customize your new deployment",
"embed" : "Embed",
"embed_info" : "To embed your map on another site use the code snippet below.",
"embed_code" : "&lt;iframe width=\"500\" height=\"400\" src=\"{{url}}\"&gt;&lt;/iframe&gt;",
"settings_list": {
"general" : "General",
"general_desc" : "Change your deployment's name, description, logo, and other details.",
Expand Down Expand Up @@ -923,6 +932,7 @@
"success" : "Registration complete! You can now log in.."
},
"post" : {
"delete_image_confirm" : "Are you sure you want to remove this image?",
"save_success" : "Post {{name}} saved",
"save_success_review" : "Post {{name}} saved. Your post will be reviewed by a moderator before publishing.",
"save_error" : "Unable to save post, please try again",
Expand Down Expand Up @@ -974,6 +984,7 @@
"bulk_role_change_success" : "User roles changed to {{role_name}}"
},
"form" : {
"add_to_survey" : "Add to survey",
"save_success" : "Survey {{name}} saved",
"save_stage_success" : "Survey task {{name}} saved",
"save_attribute_success" : "Field {{name}} added",
Expand Down
2 changes: 1 addition & 1 deletion app/common/services/endpoints/MediaEndpoint.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function (
}
},
update: {
method: 'POST'
method: 'PUT'
}
});

Expand Down
2 changes: 1 addition & 1 deletion app/common/services/endpoints/post-endpoint.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ function (
var PostEndpoint = $resource(Util.apiUrl('/posts/:id/:extra'), {
id: '@id',
order: 'desc',
orderby: 'created'
orderby: 'post_date'
}, {
query: {
method: 'GET',
Expand Down
7 changes: 6 additions & 1 deletion app/common/services/maps.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ module.exports = [
'MediaEndpoint',
'$compile',
'$rootScope',
'$window',
'CONST',
function (
$q,
Expand All @@ -25,6 +26,7 @@ function (
MediaEndpoint,
$compile,
$rootScope,
$window,
CONST
) {
var layers = {
Expand Down Expand Up @@ -115,6 +117,9 @@ function (
var Maps = {
maps: {},
config: undefined,
getZoomControlPosition: function () {
return $window.self !== $window.top ? 'bottomleft' : 'bottomright';
},
getMap: function (name) {
if (!this.maps[name]) {
this.maps[name] = Object.create(Map).init(name);
Expand All @@ -129,7 +134,7 @@ function (
getInitialScope: function () {
return {
defaults: {
zoomControlPosition: 'bottomright',
zoomControlPosition: this.getZoomControlPosition(),
scrollWheelZoom: false
},
center: { // Default to centered on Nairobi
Expand Down
12 changes: 11 additions & 1 deletion app/common/services/util.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,28 @@
module.exports = [
'_',
'CONST',
'$window',
function (
_,
CONST
CONST,
$window
) {

var Util = {
currentUrl: function () {
return $window.location.href;
},
url: function (relative_url) {
return CONST.BACKEND_URL + relative_url;
},
apiUrl: function (relative_url) {
return CONST.API_URL + relative_url;
},
deploymentUrl: function (relative_url) {
var pattern = /^(?:https?:\/\/)?(?:[^@\/\n]+@)?(?:www\.)?([^:\/\n]+)/g;
var deploymentUrl = pattern.exec(this.apiUrl(relative_url));
return deploymentUrl[0].replace('api.', '');
},
transformResponse: function (response, omitKeys) {
omitKeys = (omitKeys || []).concat(['allowed_methods']);
return _.omit(angular.fromJson(response), omitKeys);
Expand Down
8 changes: 7 additions & 1 deletion app/main/posts/collections/collections-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,10 @@ module.exports = [

// Extend filters, always adding the current collection id
var extendFilters = function (filters) {
filters = angular.copy(filters, { set : [] });
//filters = angular.copy(filters, { set : []});
filters.set = [];
filters.set.push(collection.id);

return filters;
};

Expand All @@ -53,7 +55,11 @@ module.exports = [
}, true);

// Reset GlobalFilter + add set filter
// Ensure that ALL posts are visible under collections
// Set default collection status filters
PostFilters.clearFilters();
PostFilters.setFilters({ status: ['archived', 'draft', 'published'] });
$scope.filters = extendFilters(PostFilters.getFilters());

}
];
2 changes: 2 additions & 0 deletions app/main/posts/collections/mode-context.html
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@ <h1 class="mode-context-title">
</a>
</div>

<mode-context-form-filter></mode-context-form-filter>

<post-active-filters></post-active-filters>

</div>
Expand Down
1 change: 0 additions & 1 deletion app/main/posts/common/post-actions.directive.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,3 @@ function PostActionsDirective(
}
}
}

13 changes: 4 additions & 9 deletions app/main/posts/common/post-actions.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,10 @@
<!-- Collection toggle link -->
<collection-toggle-link post="post"></collection-toggle-link>
</li>
<!-- <li>
<a href="" data-modal="share">
<svg class="iconic">
<use xlink:href="../../img/iconic-sprite.svg#share"></use>
</svg>
<span class="label">Share</span>
</a>
</li>
<li>
<li>
<post-share post-id="post.id"></post-share>
</li>
<!-- <li>
<a href="">
<svg class="iconic">
<use xlink:href="../../img/iconic-sprite.svg#task"></use>
Expand Down
14 changes: 7 additions & 7 deletions app/main/posts/common/post-metadata.directive.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,17 @@ function PostMetadataDirective(
}

function formatDates() {
var created = moment($scope.post.created),
var postDate = moment($scope.post.post_date),
now = moment();

if (now.isSame(created, 'day')) {
$scope.displayTime = created.fromNow();
} else if (now.isSame(created, 'week') && $scope.hideDateThisWeek) {
$scope.displayTime = created.format('LT');
if (now.isSame(postDate, 'day')) {
$scope.displayTime = postDate.fromNow();
} else if (now.isSame(postDate, 'week') && $scope.hideDateThisWeek) {
$scope.displayTime = postDate.format('LT');
} else {
$scope.displayTime = created.format('LL');
$scope.displayTime = postDate.format('LL');
}
$scope.displayTimeFull = created.format('LLL');
$scope.displayTimeFull = postDate.format('LLL');
}

function visibleTo(post) {
Expand Down
Loading

0 comments on commit 533401f

Please sign in to comment.