diff --git a/app/modules/web/Controllers/Helpers/AccountHelper.php b/app/modules/web/Controllers/Helpers/AccountHelper.php
index 31c8db66..2608cc85 100644
--- a/app/modules/web/Controllers/Helpers/AccountHelper.php
+++ b/app/modules/web/Controllers/Helpers/AccountHelper.php
@@ -217,9 +217,11 @@ class AccountHelper extends HelperBase
$this->view->assign('otherAccounts', $this->accountService->getForUser($this->accountId));
$this->view->assign('linkedAccounts', $this->accountService->getLinked($this->accountId));
- // FIXME: fix inline client/category creation
- $this->view->assign('addClientEnabled', $this->acl->checkUserAccess(ActionsInterface::CLIENT));
- $this->view->assign('addCategoryEnabled', $this->acl->checkUserAccess(ActionsInterface::CATEGORY));
+ $this->view->assign('addClientEnabled', !$this->view->isView && $this->acl->checkUserAccess(ActionsInterface::CLIENT));
+ $this->view->assign('addClientRoute', Acl::getActionRoute(ActionsInterface::CLIENT_CREATE));
+
+ $this->view->assign('addCategoryEnabled', !$this->view->isView && $this->acl->checkUserAccess(ActionsInterface::CATEGORY));
+ $this->view->assign('addCategoryRoute', Acl::getActionRoute(ActionsInterface::CATEGORY_CREATE));
$this->view->assign('disabled', $this->view->isView ? 'disabled' : '');
$this->view->assign('readonly', $this->view->isView ? 'readonly' : '');
diff --git a/app/modules/web/Controllers/ItemsController.php b/app/modules/web/Controllers/ItemsController.php
index c93fcc38..f57aa36f 100644
--- a/app/modules/web/Controllers/ItemsController.php
+++ b/app/modules/web/Controllers/ItemsController.php
@@ -27,7 +27,10 @@ namespace SP\Modules\Web\Controllers;
use SP\Controller\RequestControllerTrait;
use SP\Core\SessionUtil;
use SP\DataModel\DataModelInterface;
+use SP\Mvc\View\Components\SelectItemAdapter;
use SP\Services\Account\AccountService;
+use SP\Services\Category\CategoryService;
+use SP\Services\Client\ClientService;
use SP\Util\Json;
/**
@@ -74,6 +77,24 @@ class ItemsController
Json::returnJson($this->JsonResponse);
}
+ /**
+ * @throws \SP\Core\Dic\ContainerException
+ * @throws \SP\Core\Exceptions\SPException
+ */
+ public function clientsAction()
+ {
+ Json::returnRawJson((new SelectItemAdapter((new ClientService())->getAllForUser()))->getJsonItemsFromModel());
+ }
+
+ /**
+ * @throws \SP\Core\Dic\ContainerException
+ * @throws \SP\Core\Exceptions\SPException
+ */
+ public function categoriesAction()
+ {
+ Json::returnRawJson((new SelectItemAdapter((new CategoryService())->getAllBasic()))->getJsonItemsFromModel());
+ }
+
/**
* Preparar los elementos para devolverlos
*
diff --git a/app/modules/web/themes/material-blue/views/account/account.inc b/app/modules/web/themes/material-blue/views/account/account.inc
index 25dfe185..6bcd8ba5 100644
--- a/app/modules/web/themes/material-blue/views/account/account.inc
+++ b/app/modules/web/themes/material-blue/views/account/account.inc
@@ -45,7 +45,7 @@
-
-
+
getIconAdd()->getIcon(); ?>
|
@@ -78,12 +78,12 @@
value="getId(); ?>" getId() === $accountData->getCategoryId()) ? 'selected' : ''; ?>>getName(); ?>
-
+
getIconAdd()->getIcon(); ?>
diff --git a/lib/SP/Forms/AccountForm.php b/lib/SP/Forms/AccountForm.php
index cd7919e7..ec00cdb4 100644
--- a/lib/SP/Forms/AccountForm.php
+++ b/lib/SP/Forms/AccountForm.php
@@ -81,7 +81,7 @@ class AccountForm extends FormBase implements FormInterface
$this->accountRequest = new AccountRequest();
$this->accountRequest->id = $this->itemId;
$this->accountRequest->name = Request::analyze('name');
- $this->accountRequest->clientId = Request::analyze('customerId', 0);
+ $this->accountRequest->clientId = Request::analyze('clientId', 0);
$this->accountRequest->categoryId = Request::analyze('categoryId', 0);
$this->accountRequest->login = Request::analyze('login');
$this->accountRequest->url = Request::analyze('url');
diff --git a/lib/SP/Repositories/Category/CategoryRepository.php b/lib/SP/Repositories/Category/CategoryRepository.php
index a4cbb642..7287721d 100644
--- a/lib/SP/Repositories/Category/CategoryRepository.php
+++ b/lib/SP/Repositories/Category/CategoryRepository.php
@@ -89,7 +89,6 @@ class CategoryRepository extends Repository implements RepositoryItemInterface
$Data->setQuery($query);
$Data->addParam($this->makeItemHash($itemData->getName()));
$Data->addParam($itemData->getName());
- $Data->addParam($itemData->getId());
DbWrapper::getQuery($Data, $this->db);
diff --git a/lib/SP/Repositories/Client/ClientRepository.php b/lib/SP/Repositories/Client/ClientRepository.php
index 6e448120..a3921a78 100644
--- a/lib/SP/Repositories/Client/ClientRepository.php
+++ b/lib/SP/Repositories/Client/ClientRepository.php
@@ -238,10 +238,6 @@ class ClientRepository extends Repository implements RepositoryItemInterface
*/
public function delete($id)
{
- if ($this->checkInUse($id)) {
- throw new SPException(SPException::SP_WARNING, __u('No es posible eliminar'));
- }
-
$query = /** @lang SQL */
'DELETE FROM Client WHERE id = ? LIMIT 1';
diff --git a/lib/SP/Util/Json.php b/lib/SP/Util/Json.php
index f2b4b351..35c403b7 100644
--- a/lib/SP/Util/Json.php
+++ b/lib/SP/Util/Json.php
@@ -56,6 +56,18 @@ class Json
}
}
+ /**
+ * Devuelve una respuesta en formato JSON
+ *
+ * @param string $data JSON string
+ */
+ public static function returnRawJson($data)
+ {
+ header('Content-type: application/json; charset=utf-8');
+
+ exit($data);
+ }
+
/**
* Devuelve una cadena en formato JSON
*
diff --git a/public/js/app-actions.js b/public/js/app-actions.js
index c4943f4d..939851ad 100644
--- a/public/js/app-actions.js
+++ b/public/js/app-actions.js
@@ -154,10 +154,14 @@ sysPass.Actions = function (Common) {
/**
* Mostrar el contenido en una caja flotante
*
- * @param $obj
* @param response
+ * @param {Object} callback
+ * @param {function} callback.open
+ * @param {function} callback.close
*/
- var showFloatingBox = function ($obj, response) {
+ var showFloatingBox = function (response, callback) {
+ response = response || "";
+
$.magnificPopup.open({
items: {
src: response,
@@ -170,10 +174,14 @@ sysPass.Actions = function (Common) {
Common.appTriggers().views.common($boxPopup);
$boxPopup.find(":input:text:visible:first").focus();
+
+ if (typeof callback.open === "function") {
+ callback.open();
+ }
},
close: function () {
- if ($obj.data("item-dst")) {
- items.update($obj);
+ if (typeof callback.close === "function") {
+ callback.close();
}
}
},
@@ -192,7 +200,7 @@ sysPass.Actions = function (Common) {
var $image = $content.find("img");
if ($image.length === 0) {
- return showFloatingBox($obj, response);
+ return showFloatingBox(response);
}
$image.hide();
@@ -272,10 +280,13 @@ sysPass.Actions = function (Common) {
var opts = Common.appRequests().getRequestOpts();
opts.url = ajaxUrl.updateItems;
opts.method = "get";
- opts.data = {sk: Common.sk.get(), itemType: $obj.data("item-type")};
+ opts.data = {
+ r: $obj.data("item-route"),
+ sk: Common.sk.get()
+ };
Common.appRequests().getActionCall(opts, function (json) {
- callback(json.data);
+ callback(json);
});
});
}
@@ -333,7 +344,7 @@ sysPass.Actions = function (Common) {
if (response.length === 0) {
main.logout();
} else {
- showFloatingBox($obj, response);
+ showFloatingBox(response);
}
});
},
@@ -937,7 +948,7 @@ sysPass.Actions = function (Common) {
} else {
var $container = $(json.data.html);
- showFloatingBox($obj, $container);
+ showFloatingBox($container);
timeout = setTimeout(function () {
closeFloatingBox();
@@ -1132,10 +1143,12 @@ sysPass.Actions = function (Common) {
update: function ($obj) {
var $currentTab = $("#content").find("[id^='tabs-'].is-active");
- appMgmt.state.tab.refresh = !$obj.data("item-dst");
- appMgmt.state.tab.index = $currentTab.data("tab-index");
- appMgmt.state.tab.route = $currentTab.data("tab-route");
- appMgmt.state.itemId = $obj.data("item-id");
+ if ($currentTab.length > 0) {
+ appMgmt.state.tab.refresh = !$obj.data("item-dst");
+ appMgmt.state.tab.index = $currentTab.data("tab-index");
+ appMgmt.state.tab.route = $currentTab.data("tab-route");
+ appMgmt.state.itemId = $obj.data("item-id");
+ }
}
},
show: function ($obj) {
@@ -1156,7 +1169,20 @@ sysPass.Actions = function (Common) {
if (json.status !== 0) {
Common.msg.out(json);
} else {
- showFloatingBox($obj, json.data.html);
+ var $itemDst = $obj.data("item-dst");
+
+ showFloatingBox(json.data.html, {
+ open: function () {
+ if ($itemDst) {
+ appMgmt.state.tab.refresh = false;
+ }
+ },
+ close: function () {
+ if ($itemDst) {
+ items.update($obj);
+ }
+ }
+ });
}
});
},
@@ -1396,7 +1422,7 @@ sysPass.Actions = function (Common) {
if (json.status !== 0) {
Common.msg.out(json);
} else {
- showFloatingBox($obj, json.data.html);
+ showFloatingBox(json.data.html);
}
});
}
@@ -1535,7 +1561,7 @@ sysPass.Actions = function (Common) {
if (json.status !== 0) {
Common.msg.out(json);
} else {
- showFloatingBox($obj, json.data.html);
+ showFloatingBox(json.data.html);
}
});
}
diff --git a/public/js/app-actions.min.js b/public/js/app-actions.min.js
index 52495a2c..58d14803 100644
--- a/public/js/app-actions.min.js
+++ b/public/js/app-actions.min.js
@@ -4,44 +4,44 @@ $jscomp.polyfill("Array.prototype.find",function(c){return c?c:function(c,h){ret
sysPass.Actions=function(c){var e=c.log,h=0,f={entrypoint:"/index.php",doAction:"/index.php",updateItems:"/index.php",user:{savePreferences:"/ajax/ajax_userPrefsSave.php",password:"/ajax/ajax_usrpass.php",passreset:"/ajax/ajax_passReset.php"},main:{login:"/index.php?r=login/login",install:"/ajax/ajax_install.php",upgrade:"/ajax/ajax_upgrade.php",getUpdates:"/index.php?r=index/checkUpdates",task:"/ajax/ajax_task.php"},checks:"/ajax/ajax_checkConnection.php",config:{save:"/ajax/ajax_configSave.php",
"export":"/ajax/ajax_configSave.php","import":"/ajax/ajax_configSave.php"},file:"/ajax/ajax_filesMgmt.php",link:"/index.php",plugin:"/ajax/ajax_itemSave.php",account:{save:"/index.php",saveFavorite:"/ajax/ajax_itemSave.php",request:"/ajax/ajax_itemSave.php",getFiles:"/index.php",search:"/index.php?r=account/search"},appMgmt:{show:"/index.php",save:"/index.php",search:"/index.php"},eventlog:"/ajax/ajax_eventlog.php",wiki:{show:"/ajax/ajax_wiki.php"},notice:{show:"/ajax/ajax_noticeShow.php",search:"/ajax/ajax_noticeSearch.php"}};
Object.freeze(f);var k=function(a,b){var d={r:a.r+(void 0!==a.itemId?"/"+a.itemId:""),isAjax:1},g=c.appRequests().getRequestOpts();g.url=f.doAction;g.method="get";g.type="html";g.addHistory=!0;g.data=d;c.appRequests().getActionCall(g,function(a){var d=$("#content");d.empty().html(a);a=c.triggers().views;a.common(d);if(void 0!==b&&"function"===typeof a[b])a[b]();d=$(".mdl-layout__content");0