From 1eb0e2c862d89bc856c964185e5a8653d6863554 Mon Sep 17 00:00:00 2001 From: blavenie <benoit.lavenier@e-is.pro> Date: Sat, 23 Sep 2017 21:52:09 +0200 Subject: [PATCH] [fix] Page: fix comments sending [enh] Page: show only non-avatar pictures [enh] Page: parse description (URI and hashtags) --- www/plugins/es/css/style.css | 28 +++++++++++++++++++ .../es/js/controllers/common-controllers.js | 2 +- .../es/js/controllers/registry-controllers.js | 22 ++++++++++----- .../es/js/services/comment-services.js | 6 +++- .../es/js/services/registry-services.js | 10 +++++-- .../common/item_comment_content.html | 2 +- www/plugins/es/templates/registry/lookup.html | 2 +- .../es/templates/registry/lookup_lg.html | 2 +- .../templates/registry/modal_record_type.html | 8 +++--- .../es/templates/registry/view_record.html | 6 ++-- .../es/templates/user/items_profile.html | 2 +- 11 files changed, 67 insertions(+), 23 deletions(-) diff --git a/www/plugins/es/css/style.css b/www/plugins/es/css/style.css index 84c986d4..1845a1d8 100644 --- a/www/plugins/es/css/style.css +++ b/www/plugins/es/css/style.css @@ -176,3 +176,31 @@ padding-top: 8px; padding-bottom: 8px; } + +/** +* Add specific Icons +*/ + +/* Association */ +.cion-page-association:before { + font-family: "Ionicons"; + content: "\f212"; +} + +/* institution */ +.cion-page-company:before { + font-family: "Cesiumicons"; + content: "\e903"; +} + +/* institution */ +.cion-page-institution:before { + font-family: "Cesiumicons"; + content: "\e921"; +} + +/* shop */ +.cion-page-shop:before { + font-family: "Ionicons"; + content: "\f110"; +} diff --git a/www/plugins/es/js/controllers/common-controllers.js b/www/plugins/es/js/controllers/common-controllers.js index a6af511a..a9d7e779 100644 --- a/www/plugins/es/js/controllers/common-controllers.js +++ b/www/plugins/es/js/controllers/common-controllers.js @@ -206,7 +206,7 @@ function ESCommentsController($scope, $timeout, $filter, $state, $focus, UIUtils $scope.save = function() { if (!$scope.formData.message || !$scope.formData.message.length) return; - $scope.loadWallet({minData: true}) + $scope.loadWallet({minData: true, auth: true}) .then(function() { UIUtils.loading.hide(); var comment = $scope.formData; diff --git a/www/plugins/es/js/controllers/registry-controllers.js b/www/plugins/es/js/controllers/registry-controllers.js index f43e87cc..55257a9a 100644 --- a/www/plugins/es/js/controllers/registry-controllers.js +++ b/www/plugins/es/js/controllers/registry-controllers.js @@ -438,16 +438,24 @@ function ESRegistryRecordViewController($scope, $state, $q, $timeout, $ionicPopo // Load pictures esRegistry.record.picture.all({id: id}) .then(function(hit) { + var pictures; if (hit._source.pictures) { - $scope.pictures = hit._source.pictures.reduce(function(res, pic) { + pictures = hit._source.pictures.reduce(function(res, pic) { return res.concat(esHttp.image.fromAttachment(pic.file)); }, []); + if (pictures.length > 0) { + pictures.splice(0,1); // Remove the avatar + } } + $scope.pictures = pictures; + // Set Motion - $scope.motion.show({ - selector: '.lazy-load .item.card-gallery, .lazy-load .item', - startVelocity: 3000 - }); + if (pictures.length > 0) { + $scope.motion.show({ + selector: '.lazy-load .item.card-gallery, .lazy-load .item', + startVelocity: 3000 + }); + } }) .catch(function() { $scope.pictures = []; @@ -543,7 +551,7 @@ function ESRegistryRecordViewController($scope, $state, $q, $timeout, $ionicPopo } function ESRegistryRecordEditController($scope, esRegistry, UIUtils, $state, $q, Device, - $ionicHistory, ModalUtils, $focus, $timeout, esHttp) { + $ionicHistory, ModalUtils, $focus, esHttp) { 'ngInject'; $scope.walletData = {}; @@ -579,7 +587,7 @@ function ESRegistryRecordEditController($scope, esRegistry, UIUtils, $state, $q, $scope.load = function(id) { esRegistry.record.load(id, { - fetchPictures: true + raw: true }) .then(function (data) { $scope.formData = data.record; diff --git a/www/plugins/es/js/services/comment-services.js b/www/plugins/es/js/services/comment-services.js index 13d23c72..d22e9e91 100644 --- a/www/plugins/es/js/services/comment-services.js +++ b/www/plugins/es/js/services/comment-services.js @@ -125,7 +125,10 @@ angular.module('cesium.es.comment.services', ['ngResource', 'cesium.services', data.total = res.hits.total; data.result = res.hits.hits.reduce(function (result, hit) { var comment = new Comment(hit._id, hit._source); - data.mapById[comment.id] = comment; // fill map by id + // Parse URL and hashtags + comment.html = esHttp.util.trustAsHtml(comment.message); + // fill map by id + data.mapById[comment.id] = comment; return result.concat(comment); }, data.result); @@ -278,6 +281,7 @@ angular.module('cesium.es.comment.services', ['ngResource', 'cesium.services', entity = data.mapById[id]; entity.copy(comment); } + entity.html = esHttp.util.trustAsHtml(entity.message); // Send add request if (!id) { diff --git a/www/plugins/es/js/services/registry-services.js b/www/plugins/es/js/services/registry-services.js index 8df998c0..8acd1f5b 100644 --- a/www/plugins/es/js/services/registry-services.js +++ b/www/plugins/es/js/services/registry-services.js @@ -128,7 +128,8 @@ angular.module('cesium.es.registry.services', ['ngResource', 'cesium.services', function loadData(id, options) { options = options || {}; - options.fecthPictures = options.fetchPictures || false; + options.raw = angular.isDefined(options.raw) ? options.raw : false; + options.fecthPictures = angular.isDefined(options.fetchPictures) ? options.fetchPictures : options.raw; return $q.all([ @@ -145,6 +146,11 @@ angular.module('cesium.es.registry.services', ['ngResource', 'cesium.services', var hit = res[1]; var record = readRecordFromHit(hit, categories); + // parse description as Html + if (!options.raw) { + record.description = esHttp.util.trustAsHtml(record.description); + } + // Load issuer (avatar, name, uid, etc.) return csWot.extend({pubkey: record.issuer}) .then(function(issuer) { @@ -173,7 +179,7 @@ angular.module('cesium.es.registry.services', ['ngResource', 'cesium.services', picture: { all: esHttp.get('/page/record/:id?_source=pictures') }, - comment: esComment.instance('registry') + comment: esComment.instance('page') }; exports.currency = { all: esHttp.get('/currency/record/_search?_source=currencyName,peers.host,peers.port'), diff --git a/www/plugins/es/templates/common/item_comment_content.html b/www/plugins/es/templates/common/item_comment_content.html index 015e58ce..50b9cb2b 100644 --- a/www/plugins/es/templates/common/item_comment_content.html +++ b/www/plugins/es/templates/common/item_comment_content.html @@ -17,5 +17,5 @@ {{::comment.issuer|formatPubkey}} </span> </a> - <span class="text-keep-lines" ng-bind-html="::comment.message"></span> + <span class="text-keep-lines" ng-bind-html="comment.html"></span> </div> diff --git a/www/plugins/es/templates/registry/lookup.html b/www/plugins/es/templates/registry/lookup.html index a21a9ab0..0c0f5893 100644 --- a/www/plugins/es/templates/registry/lookup.html +++ b/www/plugins/es/templates/registry/lookup.html @@ -50,7 +50,7 @@ <div class="item-text-wrap item-thumbnail-left-padding" ng-class="{'item-thumbnail-left': rec.thumbnail || rec.type}"> - <i class="item-image icon cion-registry-{{::rec.type}}" ng-if="!rec.thumbnail"></i> + <i class="item-image icon cion-page-{{::rec.type}}" ng-if="!rec.thumbnail"></i> <i class="item-image" style="background-image: url({{::rec.thumbnail.src}})" ng-if="rec.thumbnail"></i> <h2 ng-bind-html="rec.title"></h2> <h4 class="gray"> diff --git a/www/plugins/es/templates/registry/lookup_lg.html b/www/plugins/es/templates/registry/lookup_lg.html index 1e3eeba6..b700ec85 100644 --- a/www/plugins/es/templates/registry/lookup_lg.html +++ b/www/plugins/es/templates/registry/lookup_lg.html @@ -72,7 +72,7 @@ <div class="row row-record "> <div class="col item-text-wrap item-thumbnail-left-padding" ng-class="{'item-thumbnail-left': rec.thumbnail || rec.type}"> - <i class="item-image icon cion-registry-{{::rec.type}}" ng-if="!rec.thumbnail"></i> + <i class="item-image icon cion-page-{{::rec.type}}" ng-if="!rec.thumbnail"></i> <i class="item-image avatar" style="background-image: url({{::rec.thumbnail.src}})" ng-if="rec.thumbnail"></i> <h2 ng-bind-html="rec.title"></h2> <h4 class="gray"> diff --git a/www/plugins/es/templates/registry/modal_record_type.html b/www/plugins/es/templates/registry/modal_record_type.html index 3f5bf7ab..c265e636 100644 --- a/www/plugins/es/templates/registry/modal_record_type.html +++ b/www/plugins/es/templates/registry/modal_record_type.html @@ -7,19 +7,19 @@ <ion-content class="lookupForm"> <div class="list padding"> <h3 translate>REGISTRY.TYPE.SELECT_TYPE</h3> - <button class="button button-block button-stable icon-left cion-registry-shop" + <button class="button button-block button-stable icon-left cion-page-shop" ng-click="closeModal('shop')" translate>REGISTRY.TYPE.ENUM.SHOP</button> - <button class="button button-block button-stable icon-left cion-registry-association" + <button class="button button-block button-stable icon-left cion-page-association" ng-click="closeModal('association')" translate>REGISTRY.TYPE.ENUM.ASSOCIATION</button> - <button class="button button-block button-stable icon-left cion-registry-company" + <button class="button button-block button-stable icon-left cion-page-company" ng-click="closeModal('company')" translate>REGISTRY.TYPE.ENUM.COMPANY</button> - <button class="button button-block button-stable icon-left cion-registry-institution" + <button class="button button-block button-stable icon-left cion-page-institution" ng-click="closeModal('institution')" translate>REGISTRY.TYPE.ENUM.INSTITUTION</button> </div> diff --git a/www/plugins/es/templates/registry/view_record.html b/www/plugins/es/templates/registry/view_record.html index cce4a49a..353ddcbf 100644 --- a/www/plugins/es/templates/registry/view_record.html +++ b/www/plugins/es/templates/registry/view_record.html @@ -15,7 +15,7 @@ <ion-content scroll="true"> <div class="positive-900-bg hero"> <div class="content" ng-if="!loading"> - <i class="avatar cion-registry-{{formData.type}}" ng-if="!formData.thumbnail"></i> + <i class="avatar cion-page-{{formData.type}}" ng-if="!formData.thumbnail"></i> <i class="avatar" style="background-image: url({{::formData.thumbnail.src}})" ng-if="formData.thumbnail"></i> <h3 ng-bind-html="formData.title"></h3> <h4> </h4> @@ -91,9 +91,7 @@ </div> <ion-item> - <h2> - <span class="text-keep-lines" ng-bind-html="formData.description"></span> - </h2> + <h2 ng-bind-html="formData.description"></h2> </ion-item> <ion-item> diff --git a/www/plugins/es/templates/user/items_profile.html b/www/plugins/es/templates/user/items_profile.html index 7ed0ae5d..10ae9417 100644 --- a/www/plugins/es/templates/user/items_profile.html +++ b/www/plugins/es/templates/user/items_profile.html @@ -10,7 +10,7 @@ <!-- About me --> <div class="item" ng-if="formData.profile.description"> <span class="gray" translate>PROFILE.DESCRIPTION</span> - <h3 class=" text-keep-lines" ng-bind-html="formData.profile.description"></h3> + <h3 class="text-keep-lines" ng-bind-html="formData.profile.description"></h3> </div> <!-- Localisation --> -- GitLab