From f8e9565f41a97419a4e5e202afe3e258b662ff60 Mon Sep 17 00:00:00 2001 From: blavenie <benoit.lavenier@e-is.pro> Date: Mon, 8 Aug 2016 14:12:00 +0200 Subject: [PATCH] - Modal: allow to give additionnal options - ES: Fix plugin injection - ES: fix registry record edition - ES : code refactoring for pictures edition --- www/i18n/locale-en.json | 2 - www/i18n/locale-fr-FR.json | 2 - www/index.html | 1 + www/js/app.js | 4 +- www/js/controllers/app-controllers.js | 4 - www/js/controllers/wallet-controllers.js | 4 +- www/js/controllers/wot-controllers.js | 4 +- www/js/plugins.js | 3 +- www/js/services/identity-services.js | 2 +- www/js/services/modal-services.js | 11 +- www/js/services/plugin-services.js | 25 ++ www/js/services/wallet-services.js | 2 +- www/plugins/es/i18n/locale-en.json | 30 ++- www/plugins/es/i18n/locale-fr-FR.json | 21 +- .../es/js/controllers/common-controllers.js | 115 ++++++++++ .../es/js/controllers/market-controllers.js | 97 +++----- .../es/js/controllers/registry-controllers.js | 81 ++----- .../es/js/controllers/user-controllers.js | 22 +- www/plugins/es/js/services/es-services.js | 16 +- www/plugins/es/js/services/user-services.js | 12 +- .../es/templates/common/edit_pictures.html | 31 +++ .../{ => common}/modal_category.html | 0 .../es/templates/market/edit_record.html | 214 ++++++++---------- www/plugins/es/templates/market/lookup.html | 2 +- .../es/templates/market/view_record.html | 4 +- .../es/templates/registry/edit_record.html | 70 +++++- .../templates/registry/new_record_wizard.html | 42 ---- .../es/templates/registry/record_form.html | 85 ------- .../es/templates/registry/view_record.html | 103 +++++---- .../user/{profile.html => edit_profile.html} | 0 www/templates/wallet/transfer_form.html | 3 +- 31 files changed, 517 insertions(+), 495 deletions(-) create mode 100644 www/plugins/es/js/controllers/common-controllers.js create mode 100644 www/plugins/es/templates/common/edit_pictures.html rename www/plugins/es/templates/{ => common}/modal_category.html (100%) delete mode 100644 www/plugins/es/templates/registry/new_record_wizard.html delete mode 100644 www/plugins/es/templates/registry/record_form.html rename www/plugins/es/templates/user/{profile.html => edit_profile.html} (100%) diff --git a/www/i18n/locale-en.json b/www/i18n/locale-en.json index e6386447..e5983c0d 100644 --- a/www/i18n/locale-en.json +++ b/www/i18n/locale-en.json @@ -26,8 +26,6 @@ "TO": "To", "COPY": "Copy", "LANGUAGE": "Language", - "BTN_PICTURE_DELETE": "Delete", - "BTN_PICTURE_FAVORISE": "Default", "UNIVERSAL_DIVIDEND": "Universal dividend", "UD": "UD", "DATE_PATTERN": "YYYY-MM-DD HH:mm", diff --git a/www/i18n/locale-fr-FR.json b/www/i18n/locale-fr-FR.json index 6a7dd304..1296eaf7 100644 --- a/www/i18n/locale-fr-FR.json +++ b/www/i18n/locale-fr-FR.json @@ -26,8 +26,6 @@ "TO": "A", "COPY": "Copier", "LANGUAGE": "Langue", - "BTN_PICTURE_DELETE": "Supprimer", - "BTN_PICTURE_FAVORISE": "Principale", "UNIVERSAL_DIVIDEND": "Dividende universel", "UD": "DU", "DATE_PATTERN": "DD/MM/YYYY HH:mm", diff --git a/www/index.html b/www/index.html index faac0227..c341a074 100644 --- a/www/index.html +++ b/www/index.html @@ -92,6 +92,7 @@ <script src="dist/dist_js/plugins/es/js/services/market-services.js"></script> <script src="dist/dist_js/plugins/es/js/services/registry-services.js"></script> <script src="dist/dist_js/plugins/es/js/services/user-services.js"></script> + <script src="dist/dist_js/plugins/es/js/controllers/common-controllers.js"></script> <script src="dist/dist_js/plugins/es/js/controllers/market-controllers.js"></script> <script src="dist/dist_js/plugins/es/js/controllers/registry-controllers.js"></script> <script src="dist/dist_js/plugins/es/js/controllers/user-controllers.js"></script> diff --git a/www/js/app.js b/www/js/app.js index 44f9edef..da066d40 100644 --- a/www/js/app.js +++ b/www/js/app.js @@ -235,7 +235,7 @@ angular.module('cesium', ['ionic', 'ionic-material', 'ngMessages', 'ngAnimate', }; }) -.run(function($rootScope, amMoment, $translate, Device, UIUtils, $ionicConfig +.run(function($rootScope, amMoment, $translate, Device, UIUtils, $ionicConfig, PluginService ) { 'ngInject'; @@ -278,5 +278,7 @@ angular.module('cesium', ['ionic', 'ionic-material', 'ngMessages', 'ngAnimate', // Set up moment translation $rootScope.$on('$translateChangeSuccess', $rootScope.onLanguageChange); + // start plugin + PluginService.start(); }) ; diff --git a/www/js/controllers/app-controllers.js b/www/js/controllers/app-controllers.js index f4c2876c..7ce750ac 100644 --- a/www/js/controllers/app-controllers.js +++ b/www/js/controllers/app-controllers.js @@ -155,10 +155,6 @@ function AppController($scope, $rootScope, $ionicModal, $state, $ionicSideMenuDe $scope.config = APP_CONFIG; $rootScope.walletData = Wallet.data; - //LoginModalController.call(this, $scope, $rootScope, $ionicModal, Wallet, CryptoUtils, UIUtils, $q, $state, $timeout, $ionicSideMenuDelegate, $ionicHistory); - - //TransferModalController.call(this, $scope, $rootScope, $ionicModal, $state, BMA, Wallet, UIUtils, $timeout, Device, $ionicPopover, $translate, $filter, $q); - //////////////////////////////////////// // Load currencies //////////////////////////////////////// diff --git a/www/js/controllers/wallet-controllers.js b/www/js/controllers/wallet-controllers.js index 68918439..7ad016e2 100644 --- a/www/js/controllers/wallet-controllers.js +++ b/www/js/controllers/wallet-controllers.js @@ -1,5 +1,5 @@ -angular.module('cesium.wallet.controllers', ['cesium.services', 'cesium.currency.controllers', 'cesium.user.services']) +angular.module('cesium.wallet.controllers', ['cesium.services', 'cesium.currency.controllers']) .config(function($stateProvider, $urlRouterProvider) { 'ngInject'; @@ -33,7 +33,7 @@ angular.module('cesium.wallet.controllers', ['cesium.services', 'cesium.currency ; function WalletController($scope, $rootScope, $state, $q, $ionicPopup, $ionicActionSheet, $timeout, - UIUtils, Wallet, BMA, $translate, Device, $ionicPopover, Modals, UserService) { + UIUtils, Wallet, BMA, $translate, Device, $ionicPopover, Modals) { 'ngInject'; $scope.walletData = null; diff --git a/www/js/controllers/wot-controllers.js b/www/js/controllers/wot-controllers.js index 5daa2ef4..9fdcbfef 100644 --- a/www/js/controllers/wot-controllers.js +++ b/www/js/controllers/wot-controllers.js @@ -49,7 +49,7 @@ angular.module('cesium.wot.controllers', ['cesium.services']) .controller('WotCertificationsViewCtrl', WotCertificationsViewController) ; -function WotLookupController($scope, BMA, $state, UIUtils, $timeout, Device, Wallet, IdentityService, UserService) { +function WotLookupController($scope, BMA, $state, UIUtils, $timeout, Device, Wallet, IdentityService) { 'ngInject'; $scope.search = { @@ -149,7 +149,7 @@ function WotLookupModalController($scope, BMA, $state, UIUtils, $timeout, Device } -function WotIdentityViewController($scope, $state, BMA, Wallet, UIUtils, $q, $timeout, Device, UserService) { +function WotIdentityViewController($scope, $state, BMA, Wallet, UIUtils, $q, $timeout, Device) { 'ngInject'; $scope.identity = {}; diff --git a/www/js/plugins.js b/www/js/plugins.js index 3d52808a..e86116cb 100644 --- a/www/js/plugins.js +++ b/www/js/plugins.js @@ -9,8 +9,9 @@ angular.module('cesium.plugins', [ 'cesium.market.services', 'cesium.user.services', // Controllers - 'cesium.registry.controllers', + 'cesium.es.controllers', 'cesium.market.controllers', + 'cesium.registry.controllers', 'cesium.user.controllers' ]) ; diff --git a/www/js/services/identity-services.js b/www/js/services/identity-services.js index c2bc2de4..4af77894 100644 --- a/www/js/services/identity-services.js +++ b/www/js/services/identity-services.js @@ -7,7 +7,7 @@ angular.module('cesium.identity.services', ['ngResource', 'ngApi', 'cesium.bma.s IdentityService = function(id) { var - api = new Api(this, id), + api = new Api(this, "IdentityService-" + id), loadRequirements = function(pubkey) { return $q(function(resolve, reject) { diff --git a/www/js/services/modal-services.js b/www/js/services/modal-services.js index 5c0ec953..71dd5eb0 100644 --- a/www/js/services/modal-services.js +++ b/www/js/services/modal-services.js @@ -4,7 +4,7 @@ angular.module('cesium.modal.services', []) 'ngInject'; - function show(templateUrl, controller, parameters) { + function show(templateUrl, controller, parameters, options) { // Grab the injector and create a new scope var deferred = $q.defer(), ctrlInstance, @@ -20,10 +20,11 @@ angular.module('cesium.modal.services', []) } }; - $ionicModal.fromTemplateUrl(templateUrl, { - scope: modalScope, - animation: 'slide-in-up' - }) + options = options ? options : {} ; + options.scope = options.scope ? options.scope : modalScope; + options.animation = options.animation ? options.animation : 'slide-in-up'; + + $ionicModal.fromTemplateUrl(templateUrl, options) .then(function (modal) { modalScope.modal = modal; diff --git a/www/js/services/plugin-services.js b/www/js/services/plugin-services.js index b64b7cd4..cc108caa 100644 --- a/www/js/services/plugin-services.js +++ b/www/js/services/plugin-services.js @@ -2,6 +2,31 @@ angular.module('cesium.plugin.services', []) +.provider('PluginService', function PluginServiceProvider() { + 'ngInject'; + + var eagerLoadingServices = []; + + this.registerEagerLoadingService = function(serviceName) { + eagerLoadingServices.push(serviceName); + }; + + this.$get = ['$injector', function pluginFactory($injector) { + + function start() { + if (eagerLoadingServices.length>0) { + _.forEach(eagerLoadingServices, function(name) { + $injector.get(name); + }); + } + } + + return { + start: start + }; + }]; +}) + .provider('$menu', function MenuProvider() { 'ngInject'; diff --git a/www/js/services/wallet-services.js b/www/js/services/wallet-services.js index 7d9ef773..da053688 100644 --- a/www/js/services/wallet-services.js +++ b/www/js/services/wallet-services.js @@ -53,7 +53,7 @@ angular.module('cesium.wallet.services', ['ngResource', 'ngApi', 'cesium.bma.ser } }, - api = new Api(this, id), + api = new Api(this, 'WalletService-' + id), resetData = function() { data.pubkey= null; diff --git a/www/plugins/es/i18n/locale-en.json b/www/plugins/es/i18n/locale-en.json index 52322da6..3834c29b 100644 --- a/www/plugins/es/i18n/locale-en.json +++ b/www/plugins/es/i18n/locale-en.json @@ -1,4 +1,14 @@ { + "COMMON": { + "CATEGORY": "Category", + "CATEGORIES": "Categories", + "CATEGORY_SEARCH_HELP": "Search", + "LAST_MODIFICATION_DATE": "Updated on ", + "BTN_PUBLISH": "Publish", + "BTN_PICTURE_DELETE": "Delete", + "BTN_PICTURE_FAVORISE": "Default", + "BTN_ADD_PICTURES": "Add pictures" + }, "MENU": { "MARKET": "Ads", "REGISTRY": "Companies", @@ -6,15 +16,11 @@ }, "MARKET": { "COMMON": { - "CATEGORY": "Category", - "CATEGORY_SEARCH_HELP": "What: car, computer, ...", - "CATEGORIES": "Categories", "ISSUER": "Issuer", "PRICE": "Price", "BTN_BUY": "Buy", "BTN_NEW_AD": "New ad", - "COMMENTS": "Comments", - "SEARCH_CATEGORY_HELP": "Search" + "COMMENTS": "Comments" }, "SEARCH": { "TITLE": "Market", @@ -35,7 +41,6 @@ }, "EDIT": { "TITLE": "Edit", - "LAST_MODIFICATION_DATE": "Updated on ", "RECORD_TITLE": "Title", "RECORD_TITLE_HELP": "Title", "RECORD_DESCRIPTION": "Description", @@ -44,11 +49,7 @@ "RECORD_LOCATION_HELP": "Address, City", "RECORD_PRICE": "Price", "RECORD_PRICE_HELP": "Price (optional)", - "RECORD_CURRENCY": "Currency", - "BTN_ADD_PICTURES": "Add pictures", - "BTN_ADD_PICTURE": "Add a picture", - "BTN_PUBLISH": "Publish", - "BTN_SAVE": "Save" + "RECORD_CURRENCY": "Currency" }, "ERROR": { "LOAD_CATEGORY_FAILED": "Error while loading market categories", @@ -60,8 +61,6 @@ "REGISTRY": { "COMMON": { "CATEGORY": "Category", - "CATEGORY_SEARCH_HELP": "What: restaurant, ...", - "CATEGORIES": "Categories", "ISSUER": "Issuer", "BTN_NEW": "Add" }, @@ -95,10 +94,7 @@ "RECORD_LOCATION": "Localization", "RECORD_LOCATION_HELP": "Localization (address, city)", "RECORD_SOCIAL_NETWORKS": "Social networks", - "RECORD_PUBKEY": "Public key", - "BTN_ADD_PICTURES": "Add pictures", - "BTN_PUBLISH": "Publish", - "BTN_SAVE": "Save" + "RECORD_PUBKEY": "Public key" }, "ERROR": { "LOAD_RECORD_FAILED": "Loading failed", diff --git a/www/plugins/es/i18n/locale-fr-FR.json b/www/plugins/es/i18n/locale-fr-FR.json index ff83d5ba..dbd41764 100644 --- a/www/plugins/es/i18n/locale-fr-FR.json +++ b/www/plugins/es/i18n/locale-fr-FR.json @@ -1,7 +1,13 @@ { "COMMON": { + "CATEGORY": "Catégorie", "CATEGORIES": "Catégories", - "CATEGORY_SEARCH_HELP": "Recherche" + "CATEGORY_SEARCH_HELP": "Recherche", + "LAST_MODIFICATION_DATE": "Mise à jour le", + "BTN_PUBLISH": "Publier", + "BTN_PICTURE_DELETE": "Supprimer", + "BTN_PICTURE_FAVORISE": "Principale", + "BTN_ADD_PICTURE": "Ajouter une photo" }, "MENU": { "MARKET": "Annonces", @@ -10,7 +16,6 @@ }, "MARKET": { "COMMON": { - "CATEGORY": "Catégorie", "ISSUER": "Soumis par", "PRICE": "Prix", "BTN_BUY": "Acheter", @@ -36,7 +41,6 @@ }, "EDIT": { "TITLE": "Edition", - "LAST_MODIFICATION_DATE": "Mise à jour le", "RECORD_TITLE": "Titre", "RECORD_TITLE_HELP": "Titre", "RECORD_DESCRIPTION": "Description", @@ -45,11 +49,7 @@ "RECORD_LOCATION_HELP": "Adresse, Ville", "RECORD_PRICE": "Prix", "RECORD_PRICE_HELP": "Prix (optionnel)", - "RECORD_CURRENCY": "Monnaie", - "BTN_ADD_PICTURES": "Ajouter des photos", - "BTN_ADD_PICTURE": "Ajouter une photo", - "BTN_PUBLISH": "Publier", - "BTN_SAVE": "Sauvegarder" + "RECORD_CURRENCY": "Monnaie" }, "ERROR": { "LOAD_CATEGORY_FAILED": "Erreur d'initialisation des catégories", @@ -94,10 +94,7 @@ "RECORD_LOCATION": "Localisation", "RECORD_LOCATION_HELP": "Localisation (adresse, ville)", "RECORD_SOCIAL_NETWORKS": "Réseaux sociaux", - "RECORD_PUBKEY": "Clé publique", - "BTN_ADD_PICTURES": "Ajouter des photos", - "BTN_PUBLISH": "Publier", - "BTN_SAVE": "Sauvegarder" + "RECORD_PUBKEY": "Clé publique" }, "ERROR": { "LOAD_RECORD_FAILED": "Chargement impossible", diff --git a/www/plugins/es/js/controllers/common-controllers.js b/www/plugins/es/js/controllers/common-controllers.js new file mode 100644 index 00000000..421c83d9 --- /dev/null +++ b/www/plugins/es/js/controllers/common-controllers.js @@ -0,0 +1,115 @@ +angular.module('cesium.es.controllers', ['cesium.services', 'ngSanitize']) + + .controller('ESPicturesEditCtrl', ESPicturesEditController) + + .controller('ESCategoryModalCtrl', ESCategoryModalController) + + .controller('ESEmptyModalCtrl', ESEmptyModalController) + +; + + +function ESPicturesEditController($scope, $ionicModal, Wallet, Market, UIUtils, $state, CryptoUtils, $q, $ionicPopup, Device, $timeout, ModalUtils) { + 'ngInject'; + + $scope.selectNewPicture = function() { + if ($scope.isDeviceEnable()){ + openPicturePopup(); + } + else { + var fileInput = angular.element(document.querySelector('#editMarket #pictureFile')); + if (fileInput && fileInput.length > 0) { + fileInput[0].click(); + } + } + }; + + $scope.openPicturePopup = function() { + Device.camera.getPicture() + .then(function(imageData) { + $scope.pictures.push({src: "data:image/png;base64," + imageData}); + $scope.$apply(); + }) + .catch(UIUtils.onError('ERROR.TAKE_PICTURE_FAILED')); + }; + + $scope.fileChanged = function(event) { + UIUtils.loading.show(); + return $q(function(resolve, reject) { + var file = event.target.files[0]; + UIUtils.image.resizeFile(file) + .then(function(imageData) { + $scope.pictures.push({src: imageData}); + UIUtils.loading.hide(); + //$scope.$apply(); + resolve(); + }); + }); + }; + + $scope.removePicture = function(index){ + $scope.pictures.splice(index, 1); + }; + + $scope.favoritePicture = function(index){ + if (index > 0) { + var item = $scope.pictures[index]; + $scope.pictures.splice(index, 1); + $scope.pictures.splice(0, 0, item); + } + }; +} + + +function ESCategoryModalController($scope, UIUtils, $timeout, parameters) { + 'ngInject'; + + $scope.loading = true; + $scope.allCategories = []; + $scope.categories = []; + this.searchText = ''; + + $scope.afterLoad = function(result) { + $scope.categories = result; + $scope.allCategories = result; + $scope.loading = false; + $timeout(function() { + UIUtils.ink(); + }, 10); + } + + this.doSearch = function() { + var searchText = this.searchText.toLowerCase().trim(); + if (searchText.length > 1) { + $scope.loading = true; + $scope.categories = $scope.allCategories.reduce(function(result, cat) { + if (cat.parent && cat.name.toLowerCase().search(searchText) != -1) { + return result.concat(cat); + } + return result; + }, []); + + $scope.loading = false; + } + else { + $scope.categories = $scope.allCategories; + } + }; + + // load categories + if (parameters && parameters.categories) { + $scope.afterLoad(parameters.categories); + } + else if (parameters && parameters.load) { + parameters.load() + .then(function(res){ + $scope.afterLoad(res); + }) + } + +} + + +function ESEmptyModalController($scope, parameters) { + +} diff --git a/www/plugins/es/js/controllers/market-controllers.js b/www/plugins/es/js/controllers/market-controllers.js index f75af3f7..7ff9f04d 100644 --- a/www/plugins/es/js/controllers/market-controllers.js +++ b/www/plugins/es/js/controllers/market-controllers.js @@ -1,4 +1,4 @@ -angular.module('cesium.market.controllers', ['cesium.services', 'ngSanitize']) +angular.module('cesium.market.controllers', ['cesium.services', 'ngSanitize', 'cesium.es.controllers']) .config(function($menuProvider) { 'ngInject'; @@ -26,7 +26,7 @@ angular.module('cesium.market.controllers', ['cesium.services', 'ngSanitize']) }) .state('app.market_view_record', { - url: "/market/:id/:title", + url: "/market/view/:id/:title", views: { 'menuContent': { templateUrl: "plugins/es/templates/market/view_record.html", @@ -48,7 +48,7 @@ angular.module('cesium.market.controllers', ['cesium.services', 'ngSanitize']) .state('app.market_edit_record', { cache: false, - url: "/market/:id/edit", + url: "/market/edit/:id/:title", views: { 'menuContent': { templateUrl: "plugins/es/templates/market/edit_record.html", @@ -64,11 +64,9 @@ angular.module('cesium.market.controllers', ['cesium.services', 'ngSanitize']) .controller('MarketRecordEditCtrl', MarketRecordEditController) - .controller('MarketCategoryModalCtrl', MarketCategoryModalController) - ; -function MarketLookupController($scope, Market, $state, $ionicModal, $focus, $timeout, UIUtils, ModalUtils) { +function MarketLookupController($scope, Market, $state, $ionicModal, $focus, $timeout, UIUtils, ModalUtils, $filter) { 'ngInject'; $scope.search = { @@ -212,7 +210,7 @@ function MarketLookupController($scope, Market, $state, $ionicModal, $focus, $ti var record = hit._source; record.id = hit._id; record.type = hit._type; - record.urlTitle = record.title; + record.urlTitle = $filter('formatSlug')(record.title); if (record.category && record.category.id) { record.category = categories[record.category.id]; } @@ -260,9 +258,15 @@ function MarketLookupController($scope, Market, $state, $ionicModal, $focus, $ti /* -- modals -- */ - $scope.showCategoryModal = function(parameters) { - ModalUtils.show('plugins/es/templates/modal_category.html', 'MarketCategoryModalCtrl as ctrl', - parameters, {focusFirstInput: true}) + $scope.showCategoryModal = function() { + // load categories + Market.category.all() + .then(function(result){ + return ModalUtils.show('plugins/es/templates/common/modal_category.html', 'ESCategoryModalCtrl as ctrl', + {categories : result}, + {focusFirstInput: true} + ) + }) .then(function(cat){ if (cat && cat.parent) { $scope.search.category = cat; @@ -273,7 +277,7 @@ function MarketLookupController($scope, Market, $state, $ionicModal, $focus, $ti } -function MarketRecordViewController($scope, $rootScope, $ionicModal, Wallet, Market, UIUtils, $state, CryptoUtils, $q, $timeout, BMA, UserService) { +function MarketRecordViewController($scope, $rootScope, $ionicModal, Wallet, Market, UIUtils, $state, CryptoUtils, $q, $timeout, BMA, UserService, ESUtils, $filter) { 'ngInject'; $scope.formData = {}; @@ -409,7 +413,7 @@ function MarketRecordViewController($scope, $rootScope, $ionicModal, Wallet, Mar $scope.$watch('$root.walletData.settings.useRelative', $scope.refreshConvertedPrice, true); $scope.edit = function() { - $state.go('app.market_edit_record', {id: $scope.id}); + $state.go('app.market_edit_record', {id: $scope.id, title: $filter('formatSlug')($scope.formData.title)}); }; $scope.showMoreComments = function(){ @@ -440,12 +444,9 @@ function MarketRecordViewController($scope, $rootScope, $ionicModal, Wallet, Mar obj.uid = walletData.uid; } obj.isnew = true; - $scope.comments.push(obj); - $scope.commentData = {}; // reset comment // Create if (!comment.id) { - // Set time (UTC) - TODO : use the block chain time - comment.time = Math.floor(moment().utc().valueOf() / 1000); + comment.time = ESUtils.date.now(); obj.time = comment.time; Market.record.comment.add(comment) .then(function (id){ @@ -458,6 +459,9 @@ function MarketRecordViewController($scope, $rootScope, $ionicModal, Wallet, Mar Market.record.comment.update(comment, {id: comment.id}) .catch(UIUtils.onError('MARKET.ERROR.FAILED_SAVE_COMMENT')); } + + $scope.comments.push(obj); + $scope.commentData = {}; // reset comment }); }; @@ -476,11 +480,9 @@ function MarketRecordViewController($scope, $rootScope, $ionicModal, Wallet, Mar }; } -function MarketRecordEditController($scope, $ionicModal, Wallet, Market, UIUtils, $state, CryptoUtils, $q, $ionicPopup, Device, $timeout, ModalUtils) { +function MarketRecordEditController($scope, $ionicModal, Wallet, Market, UIUtils, $state, CryptoUtils, $q, $ionicPopup, Device, $timeout, ModalUtils, ESUtils) { 'ngInject'; - //MarketCategoryModalController.call(this, $scope, Market, $state, $ionicModal, UIUtils, Wallet); - $scope.walletData = {}; $scope.formData = {}; $scope.id = null; @@ -550,9 +552,7 @@ function MarketRecordEditController($scope, $ionicModal, Wallet, Market, UIUtils return $q(function(resolve, reject) { var doFinishSave = function(formData) { if (!$scope.id) { // Create - // Set time (UTC) - // TODO : use the block chain time - formData.time = Math.floor(moment().utc().valueOf() / 1000); + formData.time = ESUtils.date.now(); Market.record.add(formData) .then(function(id) { $scope.id = id; @@ -564,9 +564,7 @@ function MarketRecordEditController($scope, $ionicModal, Wallet, Market, UIUtils } else { // Update if (formData.time) { - // Set time (UTC) - // TODO : use the block chain time - formData.time = Math.floor(moment().utc().valueOf() / 1000); + formData.time = ESUtils.date.now(); } Market.record.update(formData, {id: $scope.id}) .then(function() { @@ -656,9 +654,15 @@ function MarketRecordEditController($scope, $ionicModal, Wallet, Market, UIUtils /* -- modals -- */ - $scope.showCategoryModal = function(parameters) { - ModalUtils.show('plugins/es/templates/modal_category.html', 'MarketCategoryModalCtrl as ctrl', - parameters, {focusFirstInput: true}) + $scope.showCategoryModal = function() { + // load categories + Market.category.all() + .then(function(result){ + return ModalUtils.show('plugins/es/templates/common/modal_category.html', 'ESCategoryModalCtrl as ctrl', + {categories : result}, + {focusFirstInput: true} + ) + }) .then(function(cat){ if (cat && cat.parent) { $scope.category = cat; @@ -667,40 +671,3 @@ function MarketRecordEditController($scope, $ionicModal, Wallet, Market, UIUtils }); }; } - - -function MarketCategoryModalController($scope, Market, UIUtils, parameters) { - 'ngInject'; - - $scope.loading = true; - $scope.allCategories = []; - $scope.categories = []; - this.searchText = ''; - - // load categories - Market.category.all() - .then(function(result){ - $scope.categories = result; - $scope.allCategories = result; - $scope.loading = false; - UIUtils.ink(); - }); - - this.doSearch = function() { - var searchText = this.searchText.toLowerCase().trim(); - if (searchText.length > 1) { - $scope.loading = true; - $scope.categories = $scope.allCategories.reduce(function(result, cat) { - if (cat.parent && cat.name.toLowerCase().search(searchText) != -1) { - return result.concat(cat); - } - return result; - }, []); - - $scope.loading = false; - } - else { - $scope.categories = $scope.allCategories; - } - }; -} diff --git a/www/plugins/es/js/controllers/registry-controllers.js b/www/plugins/es/js/controllers/registry-controllers.js index 041915ab..e3bc90fd 100644 --- a/www/plugins/es/js/controllers/registry-controllers.js +++ b/www/plugins/es/js/controllers/registry-controllers.js @@ -1,4 +1,4 @@ -angular.module('cesium.registry.controllers', ['cesium.services', 'ngSanitize']) +angular.module('cesium.registry.controllers', ['cesium.services', 'ngSanitize', 'cesium.es.controllers']) .config(function($menuProvider) { 'ngInject'; @@ -65,10 +65,6 @@ angular.module('cesium.registry.controllers', ['cesium.services', 'ngSanitize']) .controller('RegistryRecordEditCtrl', RegistryRecordEditController) - .controller('RegistryCategoryModalCtrl', RegistryCategoryModalController) - - .controller('RegistryRecordTypeModalCtrl', RegistryRecordTypeModalController) - ; function RegistryLookupController($scope, $state, $ionicModal, $focus, $q, $timeout, Registry, UIUtils, $sanitize, ModalUtils, UserService) { @@ -240,8 +236,13 @@ function RegistryLookupController($scope, $state, $ionicModal, $focus, $q, $time /* -- modals -- */ $scope.showCategoryModal = function(parameters) { - ModalUtils.show('plugins/es/templates/modal_category.html', 'RegistryCategoryModalCtrl as ctrl', - parameters, {focusFirstInput: true}) + // load categories + Registry.category.all() + .then(function(result){ + // open modal + return ModalUtils.show('plugins/es/templates/common/modal_category.html', 'ESCategoryModalCtrl as ctrl', + {categories: result}, {focusFirstInput: true}) + }) .then(function(cat){ if (cat && cat.parent) { $scope.search.category = cat; @@ -255,7 +256,7 @@ function RegistryLookupController($scope, $state, $ionicModal, $focus, $q, $time .then(function(walletData) { UIUtils.loading.hide(); $scope.walletData = walletData; - ModalUtils.show('plugins/es/templates/registry/modal_record_type.html', 'RegistryRecordTypeModalCtrl', + ModalUtils.show('plugins/es/templates/registry/modal_record_type.html', 'ESEmptyModalCtrl', null, {focusFirstInput: true, animation: 'slide-in-down'}) .then(function(type){ if (type) { @@ -397,7 +398,7 @@ function RegistryRecordEditController($scope, $ionicModal, Wallet, Registry, UIU 'ngInject'; $scope.walletData = {}; - $scope.recordData = {}; + $scope.formData = {}; $scope.recordForm = {}; $scope.type = null; $scope.id = null; @@ -405,7 +406,7 @@ function RegistryRecordEditController($scope, $ionicModal, Wallet, Registry, UIU $scope.category = {}; $scope.pictures = []; - $scope.setRecordForm = function(recordForm) { + $scope.setForm = function(recordForm) { $scope.recordForm = recordForm; }; @@ -429,7 +430,7 @@ function RegistryRecordEditController($scope, $ionicModal, Wallet, Registry, UIU .then(function(categories) { Registry.record.get({id: id}) .then(function (hit) { - $scope.recordData = hit._source; + $scope.formData = hit._source; if (hit._source.category && hit._source.category.id){ $scope.category = categories[hit._source.category.id]; } @@ -449,11 +450,11 @@ function RegistryRecordEditController($scope, $ionicModal, Wallet, Registry, UIU $scope.save = function() { UIUtils.loading.show(); return $q(function(resolve, reject) { - $scope.recordData.pictures = $scope.pictures.reduce(function(res, pic) { + $scope.formData.pictures = $scope.pictures.reduce(function(res, pic) { return res.concat({src: pic.src}); }, []); if (!$scope.id) { // Create - Registry.record.add($scope.recordData) + Registry.record.add($scope.formData) .then(function(id) { UIUtils.loading.hide(); $state.go('app.registry_view_record', {id: id}); @@ -462,7 +463,7 @@ function RegistryRecordEditController($scope, $ionicModal, Wallet, Registry, UIU .catch(UIUtils.onError('REGISTRY.ERROR.SAVE_RECORD_FAILED')); } else { // Update - Registry.record.update($scope.recordData, {id: $scope.id}) + Registry.record.update($scope.formData, {id: $scope.id}) .then(function() { UIUtils.loading.hide(); $state.go('app.registry_view_record', {id: $scope.id}); @@ -514,54 +515,18 @@ function RegistryRecordEditController($scope, $ionicModal, Wallet, Registry, UIU /* -- modals -- */ $scope.showCategoryModal = function(parameters) { - ModalUtils.show('plugins/es/templates/modal_category.html', 'RegistryCategoryModalCtrl as ctrl', - parameters, {focusFirstInput: true}) + // load categories + Registry.category.all() + .then(function(result){ + // open modal + return ModalUtils.show('plugins/es/templates/common/modal_category.html', 'ESCategoryModalCtrl as ctrl', + {categories: result}, {focusFirstInput: true}) + }) .then(function(cat){ if (cat && cat.parent) { $scope.category = cat; - $scope.recordData.category= cat.id; + $scope.formData.category= cat.id; } }); }; } - -function RegistryCategoryModalController($scope, Registry, UIUtils, parameters) { - 'ngInject'; - - $scope.loading = true; - $scope.allCategories = []; - $scope.categories = []; - this.searchText = ''; - - // load categories - Registry.category.all() - .then(function(result){ - $scope.categories = result; - $scope.allCategories = result; - $scope.loading = false; - UIUtils.ink(); - }); - - this.doSearch = function() { - var searchText = this.searchText.toLowerCase().trim(); - if (searchText.length > 1) { - $scope.loading = true; - $scope.categories = $scope.allCategories.reduce(function(result, cat) { - if (cat.parent && cat.name.toLowerCase().search(searchText) != -1) { - return result.concat(cat); - } - return result; - }, []); - - $scope.loading = false; - } - else { - $scope.categories = $scope.allCategories; - } - }; -} - -function RegistryRecordTypeModalController($scope, parameters) { - - -} diff --git a/www/plugins/es/js/controllers/user-controllers.js b/www/plugins/es/js/controllers/user-controllers.js index 59c099df..51e743c9 100644 --- a/www/plugins/es/js/controllers/user-controllers.js +++ b/www/plugins/es/js/controllers/user-controllers.js @@ -1,12 +1,12 @@ angular.module('cesium.user.controllers', ['cesium.services', 'ngSanitize']) - .config(function($menuProvider) { + .config(function($menuProvider, $stateProvider, $urlRouterProvider) { 'ngInject'; $menuProvider.addItem({ text: 'MENU.USER_PROFILE', icon: "ion-person", section: $menuProvider.sections.USER, - url: '#/app/user/profile', + url: '#/app/user/profile/edit', ngIf: "isLogged()" }); @@ -14,26 +14,20 @@ angular.module('cesium.user.controllers', ['cesium.services', 'ngSanitize']) text: 'MENU.USER_PROFILE', icon: "ion-person", section: $menuProvider.sections.USER, - ngClick: "login('app.user_profile')", + ngClick: "login('app.user_edit_profile')", ngIf: "!isLogged()" }); - }) - - .config(function($stateProvider, $urlRouterProvider) { - 'ngInject'; - $stateProvider - - .state('app.user_profile', { - url: "/user/profile", + $stateProvider.state('app.user_edit_profile', { + url: "/user/profile/edit", views: { 'menuContent': { - templateUrl: "plugins/es/templates/user/profile.html", + templateUrl: "plugins/es/templates/user/edit_profile.html", controller: 'ProfileCtrl' } } - }) - ; + }); + }) .controller('ProfileCtrl', ProfileController) diff --git a/www/plugins/es/js/services/es-services.js b/www/plugins/es/js/services/es-services.js index ff0f1e10..7b72578f 100644 --- a/www/plugins/es/js/services/es-services.js +++ b/www/plugins/es/js/services/es-services.js @@ -5,6 +5,12 @@ angular.module('cesium.es.services', ['ngResource', 'cesium.services', 'cesium.c function ESUtils(server) { + // Get time (UTC) + function getTimeNow() { + // TODO : use the block chain time + return Math.floor(moment().utc().valueOf() / 1000); + } + function postRecord(uri) { var postRequest = HttpUtils.post(uri); @@ -16,6 +22,9 @@ angular.module('cesium.es.services', ['ngResource', 'cesium.services', 'cesium.c var errorFct = function(err) { reject(err); }; + if (!record.time) { + record.time = getTimeNow(); + } var keypair = $rootScope.walletData.keypair; var obj = {}; angular.copy(record, obj); @@ -59,8 +68,7 @@ angular.module('cesium.es.services', ['ngResource', 'cesium.services', 'cesium.c type: type, id: id, issuer: $rootScope.walletData.pubkey, - // TODO: get blockchain time ? - time: Math.floor(moment().utc().valueOf() / 1000) + time: getTimeNow() }; var str = JSON.stringify(obj); CryptoUtils.util.hash(str) @@ -82,6 +90,7 @@ angular.module('cesium.es.services', ['ngResource', 'cesium.services', 'cesium.c }; } + function login(keypair) { return $q(function(resolve, reject) { var errorFct = function(err) { @@ -149,6 +158,9 @@ angular.module('cesium.es.services', ['ngResource', 'cesium.services', 'cesium.c }, hit: { empty: emptyHit + }, + date: { + now: getTimeNow } }; } diff --git a/www/plugins/es/js/services/user-services.js b/www/plugins/es/js/services/user-services.js index 0119c186..9d12b3a8 100644 --- a/www/plugins/es/js/services/user-services.js +++ b/www/plugins/es/js/services/user-services.js @@ -1,4 +1,10 @@ angular.module('cesium.user.services', ['cesium.services', 'cesium.es.services']) +.config(function(PluginServiceProvider) { + 'ngInject'; + + PluginServiceProvider.registerEagerLoadingService('UserService'); + + }) .factory('UserService', function(APP_CONFIG, $rootScope, ESUtils, Wallet, IdentityService, UIUtils) { 'ngInject'; @@ -126,9 +132,9 @@ angular.module('cesium.user.services', ['cesium.services', 'cesium.es.services'] } // Extend Wallet.loadData() and IdentityService.loadData() - Wallet.api.data.on.load($rootScope, doLoad); - IdentityService.api.data.on.load($rootScope, doLoad); - IdentityService.api.data.on.search($rootScope, doSearch); + Wallet.api.data.on.load($rootScope, doLoad, this); + IdentityService.api.data.on.load($rootScope, doLoad, this); + IdentityService.api.data.on.search($rootScope, doSearch, this); return { profile: { diff --git a/www/plugins/es/templates/common/edit_pictures.html b/www/plugins/es/templates/common/edit_pictures.html new file mode 100644 index 00000000..c516a997 --- /dev/null +++ b/www/plugins/es/templates/common/edit_pictures.html @@ -0,0 +1,31 @@ +<div class="gallery" ng-controller="ESPicturesEditCtrl as ctrl"> + <div ng-repeat="picture in pictures" + class="item card card-gallery"> + <div> + <h2 ng-if="picture.title">{{picture.title}}</h2> + <img ng-src="{{picture.src}}" ></img> + </div> + <div class="item tabs tabs-secondary tabs-icon-left"> + <a class="tab-item stable-bg assertive-900" ng-click="removePicture($index)"> + <i class="icon ion-close"></i> + {{'COMMON.BTN_PICTURE_DELETE'|translate}} + </a> + <a class="tab-item stable-bg" + ng-click="favoritePicture($index)" + ng-class="{'dark': $index !== 0, 'positive-900': $index === 0}"> + <i class="icon ion-star"></i> + {{'COMMON.BTN_PICTURE_FAVORISE'|translate}} + </a> + </div> + </div> + <div class="item card card-gallery padding ink" + ng-click="selectNewPicture()"> + <i class="icon ion-image stable" style="font-size:150px"></i> + <b class="icon ion-plus gray" style="font-size:80px; position:absolute; top:25px; right: 5px;"></b> + <p translate>COMMON.BTN_ADD_PICTURE</p> + </div> + + <input type="file" id="pictureFile" accept=".png,.jpeg,.jpg" onchange="angular.element(this).scope().fileChanged(event)" + style="visibility:hidden; position:absolute;"/> +</div> + diff --git a/www/plugins/es/templates/modal_category.html b/www/plugins/es/templates/common/modal_category.html similarity index 100% rename from www/plugins/es/templates/modal_category.html rename to www/plugins/es/templates/common/modal_category.html diff --git a/www/plugins/es/templates/market/edit_record.html b/www/plugins/es/templates/market/edit_record.html index d15f3eba..9f8b91db 100644 --- a/www/plugins/es/templates/market/edit_record.html +++ b/www/plugins/es/templates/market/edit_record.html @@ -15,129 +15,103 @@ <div class="col col-20 hidden-xs hidden-sm"> </div> - <div class="list col"> - - <div class="item" ng-if="id"> - <h1 ng-bind-html="formData.title"></h1> - <h4 class="gray"> - <i class="icon ion-calendar"></i> - {{'MARKET.EDIT.LAST_MODIFICATION_DATE'|translate}} {{formData.time | formatDate}} - </h4> - </div> - - <div class="gallery" > - <div ng-repeat="picture in pictures" - class="item card card-gallery"> - <div> - <h2 ng-if="picture.title">{{picture.title}}</h2> - <img ng-src="{{picture.src}}" ></img> + <div class="col"> + + <form name="recordForm" novalidate="" ng-submit="save()"> + <div class="list" ng-init="setForm()"> + + <div class="item" ng-if="id"> + <h1 ng-bind-html="formData.title"></h1> + <h4 class="gray"> + <i class="icon ion-calendar"></i> + {{'COMMON.LAST_MODIFICATION_DATE'|translate}} {{formData.time | formatDate}} + </h4> </div> - <div class="item tabs tabs-secondary tabs-icon-left"> - <a class="tab-item stable-bg assertive-900" ng-click="removePicture($index)"> - <i class="icon ion-close"></i> - {{'COMMON.BTN_PICTURE_DELETE'|translate}} - </a> - <a class="tab-item stable-bg" - ng-click="favoritePicture($index)" - ng-class="{'dark': $index !== 0, 'positive-900': $index === 0}"> - <i class="icon ion-star"></i> - {{'COMMON.BTN_PICTURE_FAVORISE'|translate}} - </a> + + <!-- pictures --> + <ng-include src="'plugins/es/templates/common/edit_pictures.html'"></ng-include> + + <a class="item item-icon-right ink" ng-click="showCategoryModal()"> + <span class="item-label" translate>COMMON.CATEGORY</span> + <span class="badge badge-royal">{{category.name}}</span> + <i class="gray icon ion-ios-arrow-right"></i> + </a> + + <div class="item item-input item-floating-label"> + <span class="input-label" translate>MARKET.EDIT.RECORD_TITLE</span> + <input type="text" placeholder="{{'MARKET.EDIT.RECORD_TITLE_HELP'|translate}}" ng-model="formData.title"> </div> - </div> - <div class="item card card-gallery padding ink" - ng-click="selectNewPicture()"> - <i class="icon ion-image stable" style="font-size:150px"></i> - <b class="icon ion-plus gray" style="font-size:80px; position:absolute; top:25px; right: 5px;"></b> - <p translate>MARKET.EDIT.BTN_ADD_PICTURE</p> - </div> - </div> - - <input type="file" id="pictureFile" accept=".png,.jpeg,.jpg" onchange="angular.element(this).scope().fileChanged(event)" - style="visibility:hidden; position:absolute;"/> - - - <a class="item item-icon-right ink" ng-click="showCategoryModal()"> - <span class="item-label" translate>MARKET.COMMON.CATEGORY</span> - <span class="badge badge-royal">{{category.name}}</span> - <i class="gray icon ion-ios-arrow-right"></i> - </a> - - <div class="item item-input item-floating-label"> - <span class="input-label" translate>MARKET.EDIT.RECORD_TITLE</span> - <input type="text" placeholder="{{'MARKET.EDIT.RECORD_TITLE_HELP'|translate}}" ng-model="formData.title"> - </div> - - <div class="item item-input item-floating-label"> - <span class="input-label" translate>MARKET.EDIT.RECORD_DESCRIPTION</span> - <textarea placeholder="{{'MARKET.EDIT.RECORD_DESCRIPTION_HELP'|translate}}" - ng-model="formData.description" - rows="8" cols="10"></textarea> - </div> - - <!-- price --> - <ion-item class="item-input item-floating-label item-button-right" - ng-if="!$root.walletData.settings.useRelative"> - <span class="input-label">{{'MARKET.EDIT.RECORD_PRICE' | translate}} ({{currency | abbreviate}})</span> - <input type="text" name="price" placeholder="{{'MARKET.EDIT.RECORD_PRICE_HELP' | translate}} ({{currency | abbreviate}})" - ng-model="formData.price" - required> - <span class="gray button button-block icon ion-arrow-swap hidden-xs hidden-sm" ng-click="unitPopover.show($event)"> - </span> - <span class="gray button button-block button-clear button-icon visible-xs visible-sm" ng-click="unitPopover.show($event)"> - <i class="icon ion-android-more-vertical"></i> - </span> - </ion-item> - <ion-item class="item-input item-floating-label item-button-right" - ng-if="$root.walletData.settings.useRelative"> - <span class="input-label">{{'MARKET.EDIT.RECORD_PRICE' | translate}} ({{'COMMON.UD' | translate}}<sub>{{currency | abbreviate}}</span> - <input type="text" name="price" placeholder="{{'MARKET.EDIT.RECORD_PRICE_HELP' | translate}} ({{'COMMON.UD' | translate}} {{currency | abbreviate}})" - ng-model="formData.price" - required> - <span class="gray button button-block icon ion-arrow-swap hidden-xs hidden-sm" ng-click="unitPopover.show($event)"> - </span> - <span class="gray button button-block button-clear button-icon visible-xs visible-sm" ng-click="unitPopover.show($event)"> - <i class="icon ion-android-more-vertical"></i> - </span> - </ion-item> - - <a class="item item-icon-right ink" ng-click="openCurrencyLookup()" > - <span class="item-label gray" translate>MARKET.EDIT.RECORD_CURRENCY</span> - <span class="badge badge-royal">{{currency}}</span> - <i class="gray icon ion-ios-arrow-right"></i> - </a> - - <div class="item item-floating-label" ng-if="location.enable"> - <span class="input-label" translate>MARKET.EDIT.RECORD_LOCATION</span> - <div class="item-input-inset"> - <label class="item-input-wrapper"> - <input type="text" placeholder="{{'MARKET.EDIT.RECORD_LOCATION_HELP'|translate}}" ng-model="formData.location"> - </label> - <button class="button button-small button-positive" ng-click="localize()" ng-if="location.enable"> - <i class="icon ion-pinpoint"></i> - </button> + + <div class="item item-input item-floating-label"> + <span class="input-label" translate>MARKET.EDIT.RECORD_DESCRIPTION</span> + <textarea placeholder="{{'MARKET.EDIT.RECORD_DESCRIPTION_HELP'|translate}}" + ng-model="formData.description" + rows="8" cols="10"></textarea> </div> - </div> - - <div class="item item-input item-floating-label" ng-if="!location.enable"> - <span class="input-label" translate>MARKET.EDIT.RECORD_LOCATION</span> - <textarea placeholder="{{'MARKET.EDIT.RECORD_LOCATION_HELP'|translate}}" ng-model="formData.location"></textarea> - </div> - - - <div class="padding hidden-xs hidden-sm text-right"> - <button class="button button-clear button-dark ink" ng-click="goBack()" type="button" translate>COMMON.BTN_CANCEL - </button> - <!--<button class="button button-small button-stable ink" ng-click="saveAsDirty()">--> - <!--{{'MARKET.EDIT.BTN_SAVE' | translate}}--> - <!--</button>--> - <button class="button button-positive button-raised ink" ng-click="save()" ng-show="!id"> - {{'MARKET.EDIT.BTN_PUBLISH' | translate}} - </button> - <button class="button button-positive button-raised ink" ng-click="save()" ng-show="id"> - {{'MARKET.EDIT.BTN_SAVE' | translate}} - </button> - </div> + + <!-- price --> + <ion-item class="item-input item-floating-label item-button-right" + ng-if="!$root.walletData.settings.useRelative"> + <span class="input-label">{{'MARKET.EDIT.RECORD_PRICE' | translate}} ({{currency | abbreviate}})</span> + <input type="text" name="price" placeholder="{{'MARKET.EDIT.RECORD_PRICE_HELP' | translate}} ({{currency | abbreviate}})" + ng-model="formData.price" + required> + <span class="gray button button-block icon ion-arrow-swap hidden-xs hidden-sm" ng-click="unitPopover.show($event)"> + </span> + <span class="gray button button-block button-clear button-icon visible-xs visible-sm" ng-click="unitPopover.show($event)"> + <i class="icon ion-android-more-vertical"></i> + </span> + </ion-item> + <ion-item class="item-input item-floating-label item-button-right" + ng-if="$root.walletData.settings.useRelative"> + <span class="input-label">{{'MARKET.EDIT.RECORD_PRICE' | translate}} ({{'COMMON.UD' | translate}}<sub>{{currency | abbreviate}}</span> + <input type="text" name="price" placeholder="{{'MARKET.EDIT.RECORD_PRICE_HELP' | translate}} ({{'COMMON.UD' | translate}} {{currency | abbreviate}})" + ng-model="formData.price" + required> + <span class="gray button button-block icon ion-arrow-swap hidden-xs hidden-sm" ng-click="unitPopover.show($event)"> + </span> + <span class="gray button button-block button-clear button-icon visible-xs visible-sm" ng-click="unitPopover.show($event)"> + <i class="icon ion-android-more-vertical"></i> + </span> + </ion-item> + + <a class="item item-icon-right ink" ng-click="openCurrencyLookup()" > + <span class="item-label gray" translate>MARKET.EDIT.RECORD_CURRENCY</span> + <span class="badge badge-royal">{{currency}}</span> + <i class="gray icon ion-ios-arrow-right"></i> + </a> + + <div class="item item-floating-label" ng-if="location.enable"> + <span class="input-label" translate>MARKET.EDIT.RECORD_LOCATION</span> + <div class="item-input-inset"> + <label class="item-input-wrapper"> + <input type="text" placeholder="{{'MARKET.EDIT.RECORD_LOCATION_HELP'|translate}}" ng-model="formData.location"> + </label> + <button class="button button-small button-positive" ng-click="localize()" ng-if="location.enable"> + <i class="icon ion-pinpoint"></i> + </button> + </div> + </div> + + <div class="item item-input item-floating-label" ng-if="!location.enable"> + <span class="input-label" translate>MARKET.EDIT.RECORD_LOCATION</span> + <textarea placeholder="{{'MARKET.EDIT.RECORD_LOCATION_HELP'|translate}}" ng-model="formData.location"></textarea> + </div> + + <!-- buttons --> + <div class="padding hidden-xs hidden-sm text-right"> + <button class="button button-clear button-dark ink" ng-click="goBack()" type="button" translate> + COMMON.BTN_CANCEL + </button> + <button class="button button-positive button-raised ink" ng-click="save()" ng-if="!id" translate> + COMMON.BTN_PUBLISH + </button> + <button class="button button-assertive button-raised ink" ng-click="save()" ng-if="id" translate> + COMMON.BTN_SAVE + </button> + </div> + </div> + </form> </div> <div class="col col-20 hidden-xs hidden-sm"> </div> diff --git a/www/plugins/es/templates/market/lookup.html b/www/plugins/es/templates/market/lookup.html index bc7843e1..e0741f78 100644 --- a/www/plugins/es/templates/market/lookup.html +++ b/www/plugins/es/templates/market/lookup.html @@ -94,7 +94,7 @@ <a ng-repeat="rec in search.results" class="item item-record ink padding-xs" - ui-sref="app.market_view_record({id: rec.id, title: rec.title})" + ui-sref="app.market_view_record({id: rec.id, title: rec.urlTitle})" > <div class="visible-xs item-text-wrap" ng-class="{'item-thumbnail-left': rec.thumbnail}"> diff --git a/www/plugins/es/templates/market/view_record.html b/www/plugins/es/templates/market/view_record.html index 4c6caac6..b20217f3 100644 --- a/www/plugins/es/templates/market/view_record.html +++ b/www/plugins/es/templates/market/view_record.html @@ -60,8 +60,8 @@ <p ng-bind-html="formData.description"></p> </div> - <span class="item item-icon-left item-button-right" > - <i class="icon ion-pricetag" ng-if="formData.price"></i> + <span class="item item-icon-left item-button-right" ng-if="formData.price"> + <i class="icon ion-pricetag"></i> <span class="dark" ng-if="formData.currency && !$root.walletData.settings.useRelative">{{convertedPrice|formatInteger}} {{formData.currency|abbreviate}}</span> <span class="dark" ng-if="formData.currency && $root.walletData.settings.useRelative">{{convertedPrice|formatDecimal}} {{'COMMON.UD'|translate}} <sub>{{formData.currency|abbreviate}}</sub></span> </span> diff --git a/www/plugins/es/templates/registry/edit_record.html b/www/plugins/es/templates/registry/edit_record.html index 8df7a6b3..e9fecdcd 100644 --- a/www/plugins/es/templates/registry/edit_record.html +++ b/www/plugins/es/templates/registry/edit_record.html @@ -17,16 +17,74 @@ </div> <div class="col"> - <ng-include src="'plugins/es/templates/registry/record_form.html'"></ng-include> + <form name="recordForm" novalidate="" ng-submit="save()"> + <div class="list" ng-init="setForm(recordForm)"> + + <div class="item" ng-if="id"> + <h1 ng-bind-html="formData.title"></h1> + <h4 class="gray"> + <i class="icon ion-calendar"></i> + {{'COMMON.LAST_MODIFICATION_DATE'|translate}} {{formData.time | formatDate}} + </h4> + </div> + + <!-- pictures --> + <ng-include src="'plugins/es/templates/common/edit_pictures.html'"></ng-include> + + <span class="item item-button-right ink" ng-click="showCategoryModal()"> + <span translate>COMMON.CATEGORY</span> + <span class="badge badge-royal">{{category.name | formatCategory}}</span> + <i class="button button-clear ion-chevron-right"></i> + </span> + + <div class="item item-input item-floating-label"> + <span class="input-label" translate>REGISTRY.EDIT.RECORD_TITLE</span> + <input type="text" placeholder="{{'REGISTRY.EDIT.RECORD_TITLE_HELP'|translate}}" ng-model="formData.title" /> + </div> + + <div class="item item-input item-floating-label"> + <span class="input-label" translate>REGISTRY.EDIT.RECORD_DESCRIPTION</span> + <textarea placeholder="{{'REGISTRY.EDIT.RECORD_DESCRIPTION_HELP'|translate}}" + ng-model="formData.description" + rows="8" cols="10"> + </textarea> + </div> + + <div class="item item-floating-label" ng-if="location.enable"> + <span class="input-label" translate>REGISTRY.EDIT.RECORD_LOCATION</span> + <div class="item-input-inset"> + <label class="item-input-wrapper"> + <input type="text" placeholder="{{'REGISTRY.EDIT.RECORD_LOCATION_HELP'|translate}}" ng-model="formData.location"> + </label> + <button class="button button-small button-positive" ng-click="localize()" ng-if="location.enable"> + <i class="icon ion-pinpoint"></i> + </button> + </div> + </div> + + <div class="item item-input item-floating-label" ng-if="!location.enable"> + <span class="input-label" translate>REGISTRY.EDIT.RECORD_LOCATION</span> + <textarea placeholder="{{'REGISTRY.EDIT.RECORD_LOCATION_HELP'|translate}}" ng-model="formData.location"></textarea> + </div> + + <a class="item item-icon-left" ng-if="id && formData.issuer" > + <i class="icon ion-key"></i> + <span translate>REGISTRY.COMMON.ISSUER</span> + <h4>{{formData.issuer | formatPubkey}}</h4> + </a> + + </div> + </form> <div class="padding hidden-xs hidden-sm text-right"> - <button class="button button-clear button-dark ink" ng-click="cancel()" type="button" translate>COMMON.BTN_CANCEL + <button class="button button-clear button-dark ink" ng-click="cancel()" type="button" translate> + COMMON.BTN_CANCEL </button> - <button class="button button-positive button-raised ink" ng-click="save()" ng-show="!id"> - {{'REGISTRY.EDIT.BTN_PUBLISH' | translate}} + <button class="button button-positive button-raised ink" ng-click="save()" ng-if="!id" translate> + COMMON.BTN_PUBLISH </button> - <button class="button button-positive button-raised ink" ng-click="save()" ng-show="id"> - {{'REGISTRY.EDIT.BTN_SAVE' | translate}} + <button class="button button-assertive button-raised ink" ng-click="save()" ng-if="id" translate> + COMMON.BTN_SAVE </button> </div> </div> diff --git a/www/plugins/es/templates/registry/new_record_wizard.html b/www/plugins/es/templates/registry/new_record_wizard.html deleted file mode 100644 index f03d3124..00000000 --- a/www/plugins/es/templates/registry/new_record_wizard.html +++ /dev/null @@ -1,42 +0,0 @@ -<ion-modal-view class="modal slide-in-up ng-enter active ng-enter-active"> - - <ion-header-bar class="bar-positive"> - - <button class="button back-button button-clear buttons header-item" ng-click="slidePrev()" ng-show="slides.slider.activeIndex > 0"> - <i class="icon ion-ios-arrow-back"></i> - <span translate>COMMON.BTN_BACK</span> - </button> - <button class="button button-clear" ng-click="cancel()" ng-show="slides.slider.activeIndex == 0" translate>COMMON.BTN_CANCEL</button> - - <h1 class="title" translate>REGISTRY.NEW.TITLE</h1> - - <button class="button button-clear button-icon ion-android-send" ng-click="doNewRecord()" ng-show="slides.slider.activeIndex == 1"></button> - - </ion-nav-buttons> - </ion-header-bar> - <ion-slides options="slides.options" slider="slides.slider"> - <ion-slide-page> - <ion-content class="has-header padding"> - <h3 translate>REGISTRY.NEW.SELECT_TYPE</h3> - <button class="button button-block button-stable icon icon-left ion-person" ng-click="setIsCompany(false)" ng-class="{ selected: !isCompany && isCompany != null }" translate>REGISTRY.NEW.TYPE_PARTICULAR</button> - <button class="button button-block button-stable icon icon-left ion-android-cart" ng-click="setIsCompany(true)" ng-class="{ selected: isCompany && isCompany != null }" translate>REGISTRY.NEW.TYPE_COMPANY</button> - </ion-content> - </ion-slide-page> - <ion-slide-page> - <ion-content class="has-header"> - <ng-include src="'plugins/es/templates/registry/record_form.html'"></ng-include> - </ion-content> - </ion-slide-page> - </ion-slides> -</ion-modal-view> - -<script type="text/ng-template" id="error-messages"> - <div class="error" ng-message="required"> - <i class="ion-information-circled"></i> - <div translate="ERROR.FIELD_REQUIRED"></div> - </div> - <div class="error" ng-message="minlength"> - <i class="ion-information-circled"></i> - <div translate="ERROR.FIELD_TOO_SHORT"></div> - </div> -</script> diff --git a/www/plugins/es/templates/registry/record_form.html b/www/plugins/es/templates/registry/record_form.html deleted file mode 100644 index 85f1cdf1..00000000 --- a/www/plugins/es/templates/registry/record_form.html +++ /dev/null @@ -1,85 +0,0 @@ -<form name="recordForm" novalidate="" ng-submit="save()"> - <div class="list" - ng-init="setRecordForm(recordForm)"> - - <div class="list gallery" ng-if="pictures && pictures.length>0" > - <div ng-repeat="picture in pictures" - class="item card card-gallery"> - <div> - <h2 ng-if="picture.title">{{picture.title}}</h2> - <img ng-src="{{picture.src}}" ></img> - </div> - <div class="item tabs tabs-secondary tabs-icon-left"> - <a class="tab-item stable-bg assertive-900" ng-click="removePicture($index)"> - <i class="icon ion-close"></i> - {{'COMMON.BTN_PICTURE_DELETE'|translate}} - </a> - <a class="tab-item stable-bg" - ng-click="favoritePicture($index)" - ng-class="{'dark': $index !== 0, 'positive-900': $index === 0}"> - <i class="icon ion-star"></i> - {{'COMMON.BTN_PICTURE_FAVORISE'|translate}} - </a> - </div> - </div> - </div> - - <div class="item item-icon-right hidden-no-device"> - <span translate>REGISTRY.EDIT.BTN_ADD_PICTURES</span> - <a class="dark" href="#" ng-click="openPicturePopup()"> - <i class="icon ion-camera"></i> - </a> - </div> - - <div class="item item-input item-icon-right hidden-device"> - <span class="input-label has-input" translate>REGISTRY.EDIT.BTN_ADD_PICTURES</span> - <input type="file" id="file" accept=".png,.jpeg,.jpg" onchange="angular.element(this).scope().fileChanged(event)"/> - <!--a class="dark" href="#" ng-if="!camera" ng-click="addPictureFile()"> - <i class="icon ion-plus"></i> - </a--> - </div> - - <span class="item item-button-right ink" ng-click="showCategoryModal()"> - <span translate>REGISTRY.COMMON.CATEGORY</span> - <span class="badge badge-royal">{{category.name | formatCategory}}</span> - <i class="button button-clear ion-chevron-right"></i> - </span> - - <div class="item item-input item-floating-label"> - <span class="input-label" translate>REGISTRY.EDIT.RECORD_TITLE</span> - <input type="text" placeholder="{{'REGISTRY.EDIT.RECORD_TITLE_HELP'|translate}}" ng-model="recordData.title" /> - </div> - - <div class="item item-input item-floating-label"> - <span class="input-label" translate>REGISTRY.EDIT.RECORD_DESCRIPTION</span> - <textarea placeholder="{{'REGISTRY.EDIT.RECORD_DESCRIPTION_HELP'|translate}}" - ng-model="recordData.description" - rows="8" cols="10"> - </textarea> - </div> - - <div class="item item-floating-label" ng-if="location.enable"> - <span class="input-label" translate>REGISTRY.EDIT.RECORD_LOCATION</span> - <div class="item-input-inset"> - <label class="item-input-wrapper"> - <input type="text" placeholder="{{'REGISTRY.EDIT.RECORD_LOCATION_HELP'|translate}}" ng-model="recordData.location"> - </label> - <button class="button button-small button-positive" ng-click="localize()" ng-if="location.enable"> - <i class="icon ion-pinpoint"></i> - </button> - </div> - </div> - - <div class="item item-input item-floating-label" ng-if="!location.enable"> - <span class="input-label" translate>REGISTRY.EDIT.RECORD_LOCATION</span> - <textarea placeholder="{{'REGISTRY.EDIT.RECORD_LOCATION_HELP'|translate}}" ng-model="recordData.location"></textarea> - </div> - - <a class="item item-icon-left" ng-if="id && recordData.issuer" > - <i class="icon ion-key"></i> - <span translate>REGISTRY.COMMON.ISSUER</span> - <h4>{{recordData.issuer | formatPubkey}}</h4> - </a> - - </div> -</form> diff --git a/www/plugins/es/templates/registry/view_record.html b/www/plugins/es/templates/registry/view_record.html index 889775be..48e76d77 100644 --- a/www/plugins/es/templates/registry/view_record.html +++ b/www/plugins/es/templates/registry/view_record.html @@ -4,74 +4,87 @@ </ion-nav-title> <ion-nav-buttons side="secondary"> - <button class="button button-icon button-clear ion-android-create" ng-click="edit()" ng-if="canEdit"> + <button class="button button-icon button-clear ion-android-create visible-xs visible-sm" ng-click="edit()" ng-if="canEdit"> </button> </ion-nav-buttons> - <ion-content class="item-text-wrap"> - - <div class="scroll"> - - <div class="positive-900-bg hero"> - <div class="content"> - <div class="avatar" - ng-if="pictures && pictures.length > 0" - style="background-image: url({{pictures[0].src}});"></div> - <i class="avatar avatar-member" ng-if="!pictures || pictures.length === 0"></i> - <h3 class="light">{{formData.title}}</h3> - <h4 class="gray"> - <i class="icon ion-location" ng-show="formData.location"></i> - <span ng-bind-html="formData.location"></span> - <span ng-shwo="formData.location && formData.time"> </span> - <i class="icon ion-calendar" ng-show="formData.time"></i> - {{formData.time|formatDate}} - </h4> - </div> + <ion-content class="item-text-wrap" scroll="true"> + + <div class="positive-900-bg hero"> + <div class="content"> + <div class="avatar" + ng-if="pictures && pictures.length > 0" + style="background-image: url({{pictures[0].src}});"></div> + <i class="avatar avatar-member" ng-if="!pictures || pictures.length === 0"></i> + <h3 class="light">{{formData.title}}</h3> + <h4 class="gray"> + <i class="icon ion-location" ng-show="formData.location"></i> + <span ng-bind-html="formData.location"></span> + <span ng-shwo="formData.location && formData.time"> </span> + <i class="icon ion-calendar" ng-show="formData.time"></i> + {{formData.time|formatDate}} + </h4> </div> + </div> + + <div class="row"> + <div class="col col-20 hidden-xs hidden-sm"> + </div> - <div class="hidden-xs hidden-sm padding text-center"> + <div class="col list"> + + <!-- Buttons bar--> + <div class="item padding hidden-xs hidden-sm text-center" + ng-if="!canEdit"> <button class="button button-raised button-assertive ink-dark" ng-click="transfer(formData.issuer, formData.title)"> {{'ACCOUNT.BTN_SEND_MONEY' | translate}} </button> - <button class="button button-raised button-icon icon ion-ribbon-b" ng-click="certifyIdentity()" ng-if="hasSelf"> {{'WOT.BTN_CERTIFY' | translate}} </button> </div> - <div class="list"> + <div class="item padding text-right" + ng-if="canEdit"> + <button class="button button-assertive button-raised icon-left ion-android-create hidden-xs hidden-sm ink" + ng-click="edit()"> + {{'COMMON.BTN_EDIT' | translate}} + </button> + </div> - <span class="item item-icon-left ink" - ng-if="!isCompany" - copy-on-click> - <i class="icon ion-key"></i> - <p class="gray">{{formData.issuer}}</p> - </span> + <span class="item item-icon-left ink" + ng-if="!isCompany" + copy-on-click> + <i class="icon ion-key"></i> + <p class="gray">{{formData.issuer}}</p> + </span> + + <div class="item"> + <p ng-bind-html="formData.description"></p> + </div> + + <div ng-if="isCompany"> + <div class="item-divider"></div> <div class="item"> - <p ng-bind-html="formData.description"></p> + <span translate>COMMON.CATEGORY</span> + <span class="badge badge-positive">{{category.name || formatCategory}}</span> </div> - <div ng-if="isCompany"> - <div class="item-divider"></div> - - <div class="item"> - <span translate>REGISTRY.COMMON.CATEGORY</span> - <span class="badge badge-positive">{{category.name || formatCategory}}</span> - </div> + <span class="item item-icon-left" > + <i class="icon ion-person"></i> + <h3><span translate>REGISTRY.COMMON.ISSUER</span></h3> + <span class="badge" ng-class="{'badge-positive': isMember, 'badge-assertive': !isMember}">{{formData.issuer | formatPubkey}}</span> + </span> - <span class="item item-icon-left" > - <i class="icon ion-person"></i> - <h3><span translate>REGISTRY.COMMON.ISSUER</span></h3> - <span class="badge" ng-class="{'badge-positive': isMember, 'badge-assertive': !isMember}">{{formData.issuer | formatPubkey}}</span> - </span> + </div> - </div> + </div> - </div> - <div class="scroll-bar scroll-bar-v"></div> + <div class="col col-20 hidden-xs hidden-sm"> </div> + </div> </ion-content> <button class="button button-fab button-fab-bottom-right button-assertive icon ion-android-send visible-xs visible-sm" diff --git a/www/plugins/es/templates/user/profile.html b/www/plugins/es/templates/user/edit_profile.html similarity index 100% rename from www/plugins/es/templates/user/profile.html rename to www/plugins/es/templates/user/edit_profile.html diff --git a/www/templates/wallet/transfer_form.html b/www/templates/wallet/transfer_form.html index 98319c9f..b03afa06 100644 --- a/www/templates/wallet/transfer_form.html +++ b/www/templates/wallet/transfer_form.html @@ -1,5 +1,4 @@ - <form name="transferForm" novalidate="" ng-submit="doTransfer()" - > + <form name="transferForm" novalidate="" ng-submit="doTransfer()"> <div class="list" ng-init="setForm(transferForm)"> -- GitLab