first commit
This commit is contained in:
17
apps/backend/modules/stCategory/templates/_addToManager.php
Normal file
17
apps/backend/modules/stCategory/templates/_addToManager.php
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php use_helper('stAdminGenerator') ?>
|
||||
<?php use_stylesheet('backend/stCategory.css') ?>
|
||||
<?php foreach ($iterators as $iterator): ?>
|
||||
<h3>
|
||||
<?php echo $iterator->getRoot()->getName() ?>
|
||||
</h3>
|
||||
<ul id="st_category_tree-list">
|
||||
<?php foreach ($iterator->getDescendants() as $descendat): ?>
|
||||
<li style="margin-left: <?php echo $descendat->getLevel()*20 ?>px">
|
||||
<?php echo checkbox_tag('category['.$descendat->getId().']', $descendat->getId(), $descendat->hasDatabaseRecord($object) || $sf_request->getParameter('category['.$descendat->getId().']')) ?>
|
||||
<?php echo label_for('category['.$descendat->getId().']', $descendat->getName()) ?>
|
||||
<br class="st_clear_all" />
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
<br class="st_clear_all" />
|
||||
<?php endforeach; ?>
|
||||
12
apps/backend/modules/stCategory/templates/_categories.php
Normal file
12
apps/backend/modules/stCategory/templates/_categories.php
Normal file
@@ -0,0 +1,12 @@
|
||||
<ul class="open">
|
||||
<?php foreach ($parent->getChildren('doSelectWithI18n') as $child): ?>
|
||||
|
||||
<li class="<?php echo isset($expanded[$child->getId()]) ? ' selected' : '' ?> children">
|
||||
<?php if ($child->hasChildren()): ?><span class="expandable<?php echo isset($expanded[$child->getId()]) ? ' open' : '' ?>" style="padding-left: <?php echo ($child->getDepth() - 1) * 9 ?>px"></span><?php else: ?><span class="leaf"></span><?php endif; ?><a href="<?php echo $url ?>?category_id=<?php echo $child->getId() ?>" data-id="<?php echo $child->getId() ?>" style="padding-left: <?php echo ($child->getDepth() - 1) * 10 + 27 ?>px"><?php echo $child->getName() ?></a>
|
||||
<?php if ($child->hasChildren() && isset($expanded[$child->getId()])): ?>
|
||||
<?php echo st_get_partial('stCategory/categories', array('parent' => $child, 'expanded' => $expanded, 'selected' => $selected, 'url' => $url)) ?>
|
||||
<?php endif; ?>
|
||||
</li>
|
||||
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
22
apps/backend/modules/stCategory/templates/_categoryRow.php
Normal file
22
apps/backend/modules/stCategory/templates/_categoryRow.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
/**
|
||||
* Szablon pomocniczy prezentujący pojedynczy element kategorii
|
||||
*/
|
||||
?>
|
||||
<span class="st_category_tree-<?php echo $categoryTree->getLevel() > 1 ? 'child' : 'parent' ?>">
|
||||
<?php if (!$categoryTree->isRoot()): ?>
|
||||
<span class="st_category_tree-nest-number">
|
||||
<?php echo stNestedIterator::getDepthNumber($categoryTree) ?>
|
||||
</span>
|
||||
<?php endif; ?>
|
||||
<span class="st_category_tree-name" id="category_<?php echo $categoryTree->getId() ?>">
|
||||
<?php echo $categoryTree->getName() ?>
|
||||
</span>
|
||||
</span>
|
||||
<?php st_include_partial('category_menu', array('categoryTree' => $categoryTree)) ?>
|
||||
<br style="clear: both" />
|
||||
<?php echo input_in_place_editor_tag('category_'.$categoryTree->getId(),'category/categoryEdit?id='.$categoryTree->getId(), array(
|
||||
'cols' => 20,
|
||||
'rows' => 1,
|
||||
'complete' => " { var options = \$A($('st_tree_list').options); options.each(function(option) { if (option.value == {$categoryTree->getId()}) option.text = $('category_{$categoryTree->getId()}').innerHTML; }); }",
|
||||
)) ?>
|
||||
26
apps/backend/modules/stCategory/templates/_category_menu.php
Normal file
26
apps/backend/modules/stCategory/templates/_category_menu.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php if (!$categoryTree->isRoot()): ?>
|
||||
<ul class="st_category_tree-menu">
|
||||
<li <?php echo get_tooltip('Awansuj kategorię') ?>>
|
||||
<?php echo link_to(image_tag('/images/backend/category_tree/arrows/arrow_left.png'), 'category/promote?id='.$categoryTree->getId()) ?>
|
||||
</li>
|
||||
<li <?php echo get_tooltip('Przesuń kategorię w górę') ?>>
|
||||
<?php echo link_to(image_tag('/images/backend/category_tree/arrows/arrow_up.png'), 'category/moveUp?id='.$categoryTree->getId()) ?>
|
||||
</li>
|
||||
<li <?php echo get_tooltip('Przesuń kategorię w dół') ?>>
|
||||
<?php echo link_to(image_tag('/images/backend/category_tree/arrows/arrow_down.png'), 'category/moveDown?id='.$categoryTree->getId()) ?>
|
||||
</li>
|
||||
<li <?php echo get_tooltip('Degraduj kategorię') ?>>
|
||||
<?php echo link_to(image_tag('/images/backend/category_tree/arrows/arrow_right.png'), 'category/degrade?id='.$categoryTree->getId()) ?>
|
||||
</li>
|
||||
<li <?php echo get_tooltip('Przejdź do edycji kategorii') ?>>
|
||||
<?php echo link_to(image_tag('backend/icons/edit.png'), 'category/edit?id='.$categoryTree->getId()) ?>
|
||||
</li>
|
||||
<li <?php echo get_tooltip('Usuń kategorię - usuwa daną kategorię wraz z jej podkategoriami') ?>>
|
||||
<?php echo link_to(image_tag('backend/icons/delete.png'), 'category/delete?id='.$categoryTree->getId()) ?>
|
||||
</li>
|
||||
</ul>
|
||||
<?php else: ?>
|
||||
<ul class="st_category_tree-menu">
|
||||
<li <?php echo get_tooltip('Usuń drzewo') ?>><?php echo link_to(image_tag('backend/icons/delete.png'), 'category/delete?id='.$categoryTree->getId()) ?></li>
|
||||
</ul>
|
||||
<?php endif; ?>
|
||||
@@ -0,0 +1,10 @@
|
||||
<div id="category_tree_name">
|
||||
<div>
|
||||
<?php echo input_tag($name, null) ?>
|
||||
</div>
|
||||
<div>
|
||||
<?php echo st_get_admin_actions(array(
|
||||
array("label" => __("Dodaj"), "type" => "create")
|
||||
)) ?>
|
||||
</div>
|
||||
</div>
|
||||
15
apps/backend/modules/stCategory/templates/_category_url.php
Normal file
15
apps/backend/modules/stCategory/templates/_category_url.php
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php $category = $category_has_positioning->getCategory();?>
|
||||
|
||||
<?php echo input_tag('category_has_positioning[category_url]', $category->getFriendlyUrl(), array('size' => '80')) ?>
|
||||
|
||||
<?php list($culture) = explode('_', $category->getCulture()); ?>
|
||||
|
||||
<p>
|
||||
<?php echo st_link_to(null, 'stProduct/frontendList?url=' . $category->getFriendlyUrl(), array(
|
||||
'absolute' => true,
|
||||
'for_app' => 'frontend',
|
||||
'for_lang' => $culture,
|
||||
'no_script_name' => true,
|
||||
'class' => 'st_admin_external_link',
|
||||
'target' => '_blank')) ?>
|
||||
</p>
|
||||
28
apps/backend/modules/stCategory/templates/_cathor_tree.php
Normal file
28
apps/backend/modules/stCategory/templates/_cathor_tree.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
$c = new Criteria();
|
||||
$c->add(CategoryPeer::PARENT_ID, NULL);
|
||||
$categories = CategoryPeer::doSelect($c);
|
||||
|
||||
if($categories)
|
||||
{
|
||||
foreach ($categories as $category)
|
||||
{
|
||||
$select[$category->getId()] = $category->getOptName();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$select = 0;
|
||||
}
|
||||
?>
|
||||
<label><?php echo __('Drzewo kategorii') ?></label>
|
||||
<div class="content">
|
||||
<?php if($select!=0): ?>
|
||||
<?php echo select_tag('config[cathor_tree]', options_for_select($select,
|
||||
array($config->get('cathor_tree'))
|
||||
)) ?>
|
||||
<?php else: ?>
|
||||
<?php echo __('Brak drzew kategorii'); ?>
|
||||
<?php endif; ?>
|
||||
<br class="st_clear_all">
|
||||
</div>
|
||||
@@ -0,0 +1 @@
|
||||
<?php use_javascript('backend/stCategory.js?version=1') ?>
|
||||
4
apps/backend/modules/stCategory/templates/_edit_url.php
Normal file
4
apps/backend/modules/stCategory/templates/_edit_url.php
Normal file
@@ -0,0 +1,4 @@
|
||||
<?php echo input_tag('category[edit_url]', $category->getUrl(), array('disabled' => $category->getAutoGenerateUrl(), 'size' => '64')) ?>
|
||||
|
||||
<?php echo checkbox_tag('category[auto_generate_url]', true, $category->getAutoGenerateUrl(), array('onchange' => "$('category_edit_url').disabled = this.checked")) ?>
|
||||
<?php echo label_for('category_auto_generate_url', __('Generuj automatycznie'), array('style' => 'float: none; display: inline; padding: 0px')) ?>
|
||||
12
apps/backend/modules/stCategory/templates/_image.php
Normal file
12
apps/backend/modules/stCategory/templates/_image.php
Normal file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
use_helper('stCategoryImage', 'stJQueryTools');
|
||||
|
||||
$images = array();
|
||||
|
||||
if (!$category->isNew() && $category->getSfAsset())
|
||||
{
|
||||
$images[$category->getSfAssetId()] = st_category_image_path($category, 'full');
|
||||
}
|
||||
|
||||
echo plupload_images_tag('category_images', $images, array('crop' => 'category', 'limit' => 1));
|
||||
?>
|
||||
@@ -0,0 +1 @@
|
||||
<?php echo image_tag('/'.sfConfig::get('sf_upload_dir_name')."/photos/".$category->getImage())?>
|
||||
8
apps/backend/modules/stCategory/templates/_is_active.php
Normal file
8
apps/backend/modules/stCategory/templates/_is_active.php
Normal file
@@ -0,0 +1,8 @@
|
||||
|
||||
<?php echo st_admin_checkbox_tag('category[is_active]', 1, $category->getIsActive(), array (
|
||||
'disabled' => $category->hasParent() && $category->getParent() && !$category->getParent()->getIsActive()
|
||||
)); ?>
|
||||
|
||||
<?php if ($category->hasParent() && $category->getParent() && !$category->getParent()->getIsActive()): ?>
|
||||
<a href="#" class="help" style="vertical-align: middle" title="<?php echo __('Nie możesz aktywować kategorii w przypadku, gdy kategoria narzędna jest nieaktywna') ?>"></a>
|
||||
<?php endif ?>
|
||||
1
apps/backend/modules/stCategory/templates/_lang.php
Normal file
1
apps/backend/modules/stCategory/templates/_lang.php
Normal file
@@ -0,0 +1 @@
|
||||
<?php st_include_component('stLanguageBackend', 'showLanguages')?>
|
||||
3
apps/backend/modules/stCategory/templates/_main_page.php
Normal file
3
apps/backend/modules/stCategory/templates/_main_page.php
Normal file
@@ -0,0 +1,3 @@
|
||||
<?php echo st_admin_checkbox_tag('category[main_page]', 1, $category->getMainPage(), array (
|
||||
'disabled' => $category->isRoot(),
|
||||
)); ?>
|
||||
@@ -0,0 +1,3 @@
|
||||
<?php echo st_admin_checkbox_tag('category[show_children_products]', 1, $category->getShowChildrenProducts(), array (
|
||||
'disabled' => stConfig::getInstance('stCategory')->get('show_children_products'),
|
||||
)); ?>
|
||||
40
apps/backend/modules/stCategory/templates/_tree.php
Normal file
40
apps/backend/modules/stCategory/templates/_tree.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<ul style="--menu-items: <?php echo count($roots) ?>">
|
||||
<li>
|
||||
<ul id="st_category_tree_filter" class="st_category_tree_filter">
|
||||
<?php foreach ($roots as $root): ?>
|
||||
<li class="category_tree">
|
||||
<div class="preloader cover" style="display: none; height: 100%; width: 100%"></div>
|
||||
<ul>
|
||||
<li>
|
||||
<span class="name-tree"><?php echo $root->getName() ?></span>
|
||||
<?php echo st_get_partial('stCategory/categories', array('parent' => $root, 'expanded' => $expanded, 'selected' => $selected, 'url' => $url)) ?>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<?php endforeach ?>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<script type="text/javascript">
|
||||
jQuery(function($) {
|
||||
$('#st_category_tree_filter').on('click', '.expandable', function() {
|
||||
let image = $(this);
|
||||
let link = image.next();
|
||||
let preloader = link.closest('.category_tree').find('.preloader');
|
||||
|
||||
if (!link.next('ul').length) {
|
||||
preloader.show();
|
||||
$.post("<?php echo st_url_for('@stCategory?action=ajaxCategoryFilterChildren') ?>?id="+link.data('id'), { url: "<?php echo $url ?>" }, function(data) {
|
||||
link.after(data);
|
||||
image.addClass('open');
|
||||
link.next().addClass('open');
|
||||
preloader.hide();
|
||||
});
|
||||
} else {
|
||||
image.toggleClass('open');
|
||||
link.next().toggleClass('open');
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
@@ -0,0 +1,19 @@
|
||||
<ul class="category_breadcrumbs">
|
||||
<li><a href="<?php echo $url ?>?filters[category]="><?php echo __('Wszystkie') ?></a></li>
|
||||
<?php foreach ($breadcrumbs as $category): $id = $category->getId(); ?>
|
||||
<li>›</li>
|
||||
<?php if ($category->isRoot()): ?>
|
||||
<li>
|
||||
<?php echo $category->getName() ?>
|
||||
</li>
|
||||
<?php elseif ($category->getId() == $selected): ?>
|
||||
<li>
|
||||
<?php echo $category->getName() ?>
|
||||
</li>
|
||||
<?php else: ?>
|
||||
<li>
|
||||
<a href="<?php echo $url ?>?filters[category]=<?php echo $category->getId() ?>"><?php echo $category->getName() ?></a>
|
||||
</li>
|
||||
<?php endif; ?>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
4
apps/backend/modules/stCategory/templates/addSuccess.php
Normal file
4
apps/backend/modules/stCategory/templates/addSuccess.php
Normal file
@@ -0,0 +1,4 @@
|
||||
<?php use_helper('Javascript'); ?>
|
||||
<li style="margin-left: <?php echo $categoryTree->getLevel() * 20 ?>px">
|
||||
<?php st_include_partial('categoryRow', array('categoryTree' => $categoryTree)); ?>
|
||||
</li>
|
||||
@@ -0,0 +1,4 @@
|
||||
<?php use_helper('stAdminGenerator') ?>
|
||||
<?php echo st_get_admin_head('stCategory', 'Test dodawania produktu', '') ?>
|
||||
<?php st_include_component('stCategory', 'addToManager', array('product_id' => $product_id)) ?>
|
||||
<?php echo st_get_admin_foot() ?>
|
||||
@@ -0,0 +1,90 @@
|
||||
<div id="<?php echo $tree_id ?>" style="padding: 0px 10px 10px 0px">
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
|
||||
jQuery(function($) {
|
||||
$.getScript('/jQueryTools/jstree/js/jstree.min.js?v1', function() {
|
||||
var jstree = $("#<?php echo $tree_id ?>");
|
||||
var limit = <?php echo $limit ?>;
|
||||
jstree.jstree({
|
||||
themes: {
|
||||
url: "/jQueryTools/jstree/themes/default/style.css",
|
||||
theme: 'default'
|
||||
},
|
||||
html_data: {
|
||||
ajax: {
|
||||
url: function(node) {
|
||||
var id = node ? node.attr('id').replace('<?php echo $tree_id ?>-', '') : 0;
|
||||
return "<?php echo st_url_for('@stCategoryAction?action=ajaxCategoryChildren') ?>?id="+id+"&default=<?php echo $default ?>&tree_id=<?php echo $tree_id ?>";
|
||||
},
|
||||
data: { assigned: "<?php echo $sf_request->getParameter('assigned') ?>", show_default: <?php echo $show_default ?>, 'limit': <?php echo $limit ?> },
|
||||
type: 'POST'
|
||||
},
|
||||
data: '<?php echo $html_data ?>'
|
||||
},
|
||||
plugins: ["themes", "html_data"]
|
||||
});
|
||||
|
||||
jstree.data('assigned', <?php echo json_encode(explode(',', $sf_request->getParameter('assigned'))) ?>);
|
||||
jstree.change(function(event) {
|
||||
var target = $(event.target).filter('input.assigned');
|
||||
|
||||
if (target.length) {
|
||||
var id = event.target.value;
|
||||
|
||||
console.log("input_id: " + id);
|
||||
|
||||
var instance = $.jstree._reference(jstree);
|
||||
|
||||
var settings = instance.get_settings();
|
||||
|
||||
var added = jstree.data('added') ? jstree.data('added') : [];
|
||||
|
||||
var removed = jstree.data('removed') ? jstree.data('removed') : [];
|
||||
|
||||
var assigned = jstree.data('assigned');
|
||||
|
||||
var input = $(event.target).next('input');
|
||||
|
||||
input.attr('disabled', !event.target.checked);
|
||||
|
||||
if (event.target.checked) {
|
||||
if (1 == limit) {
|
||||
added = [id];
|
||||
} else if (added.indexOf(id) < 0 && assigned.indexOf(id) < 0) {
|
||||
added.push(id);
|
||||
}
|
||||
|
||||
var tmp = removed.indexOf(id);
|
||||
|
||||
if (tmp > -1) {
|
||||
removed.splice(tmp, 1);
|
||||
}
|
||||
} else {
|
||||
if (removed.indexOf(id) < 0) {
|
||||
removed.push(id);
|
||||
}
|
||||
|
||||
var tmp = added.indexOf(id);
|
||||
|
||||
if (tmp > -1) {
|
||||
added.splice(tmp, 1);
|
||||
}
|
||||
}
|
||||
console.log(added);
|
||||
|
||||
jstree.data('added', added);
|
||||
|
||||
jstree.data('removed', removed);
|
||||
|
||||
if (event.target.checked) {
|
||||
if (jstree.find('input.default-assigned:enabled:checked').length == 0) {
|
||||
input.attr('checked', true);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
</script>
|
||||
@@ -0,0 +1,7 @@
|
||||
<ul>
|
||||
<?php foreach ($roots as $root): ?>
|
||||
<li>
|
||||
<a href="#"><?php echo $root->getOptName() ?></a>
|
||||
</li>
|
||||
<?php endforeach ?>
|
||||
</ul>
|
||||
204
apps/backend/modules/stCategory/templates/managerSuccess.php
Normal file
204
apps/backend/modules/stCategory/templates/managerSuccess.php
Normal file
@@ -0,0 +1,204 @@
|
||||
<?php
|
||||
use_helper("stAdminGenerator");
|
||||
use_stylesheet("backend/stCategory.css?v4");
|
||||
use_javascript("/jQueryTools/jstree/js/jstree.min.js?v1");
|
||||
?>
|
||||
|
||||
<?php st_include_partial("stCategory/header", array("title" => __("Menedżer kategorii"), 'favorite' => array('add_title' => false))) ?>
|
||||
<?php st_include_partial('stCategory/list_menu'); ?>
|
||||
<?php st_include_partial('stAdminGenerator/message'); ?>
|
||||
|
||||
<div>
|
||||
|
||||
<form id="category_tree_form" class="admin_form" action="<?php echo st_url_for("stCategory/addTree") ?>" method="post">
|
||||
<?php echo st_admin_section_start(); ?>
|
||||
<?php echo st_admin_get_form_field('category_tree_name', __("Nazwa drzewa"), $sf_request->getParameter("category_tree_name"), '_category_tree_name') ?>
|
||||
<?php echo st_admin_section_end() ?>
|
||||
</form>
|
||||
|
||||
<div id="category_tree_container">
|
||||
<?php foreach ($roots as $root): $id = $root["metadata"]["id"]; ?>
|
||||
<div class="category_tree">
|
||||
<div class="category_tree_actions">
|
||||
<a class="category_tree_action help" href="<?php echo st_url_for("@stCategory?action=delete&id=".$id) ?>" title="<?php echo __("Usuń drzewo", null, "stCategoryTree") ?>" data-admin-confirm="<?php echo __("Zamierzasz usunąć całe drzewo kategorii. Jesteś pewien, że chcesz kontynuować?", null, "stCategoryTree") ?>" data-admin-action="delete"><?php echo st_admin_get_icon('delete') ?></a>
|
||||
<a class="category_tree_action help" <?php echo $root["metadata"]["root-position"] <= 1 ? " disabled" : "" ?>" href="<?php echo st_url_for("@stCategory?action=setRootPosition&move=up&id=".$id) ?>" title="<?php echo __("Przenieś drzewo do góry", null, "stCategoryTree") ?>"><?php echo st_admin_get_icon('prev') ?></a>
|
||||
<a class="category_tree_action help" <?php echo $root["metadata"]["root-position"] >= $maxRootPosition ? " disabled" : "" ?>" href="<?php echo st_url_for("@stCategory?action=setRootPosition&move=down&id=".$id) ?>" title="<?php echo __("Przenieś drzewo w dół", null, "stCategoryTree") ?>"><?php echo st_admin_get_icon('next') ?></a>
|
||||
</div>
|
||||
<div id="category_tree_<?php echo $id ?>"></div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
jQuery(function($) {
|
||||
$("#category_tree_<?php echo $id ?>").jstree({
|
||||
"core": {
|
||||
"animation": 100
|
||||
},
|
||||
"plugins": ["themes", "json_data", "dnd", "ui", "crrm", "contextmenu"],
|
||||
"themes": {
|
||||
"url": "/jQueryTools/jstree/themes/default/style.css",
|
||||
"theme": "default"
|
||||
},
|
||||
"crrm": {
|
||||
"move": {
|
||||
"check_move": function(m) {
|
||||
if (("after" == m.p || "before" == m.p) && this._get_parent(m.r) < 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this._get_parent(m.o) < 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
},
|
||||
"json_data": {
|
||||
"progressive_render": true,
|
||||
"progressive_unload": true,
|
||||
"data": function(node, cb) {
|
||||
if (node == -1) {
|
||||
cb(<?php echo json_encode($root) ?>);
|
||||
} else {
|
||||
$.get("<?php echo st_url_for("@stCategory?action=ajaxJstreeJson") ?>", { "id": node.data("id") } , function(response) {
|
||||
cb(response);
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
"ui": {
|
||||
"select_limit": 1,
|
||||
"initially_select": ["<?php echo $sf_request->getParameter('category_id') ? "category-".$sf_request->getParameter('category_id') : "" ?>"]
|
||||
},
|
||||
"contextmenu": {
|
||||
"select_node": true,
|
||||
"items": function(node) {
|
||||
var items = {
|
||||
"create": {
|
||||
"label": "<?php echo __("Dodaj", null, "stCategoryTree") ?>",
|
||||
"action": function(node) {
|
||||
this.create(node, "last", {
|
||||
data: "<?php echo __("Nowa kategoria", null, "stCategoryTree") ?>",
|
||||
});
|
||||
},
|
||||
"separator_after": true,
|
||||
},
|
||||
rename: {
|
||||
"label": "<?php echo __("Zmień nazwę", null, "stCategoryTree") ?>",
|
||||
"action": function(node) {
|
||||
this.rename(node);
|
||||
}
|
||||
},
|
||||
"remove": {
|
||||
"label": "<?php echo __("Usuń", null, "stCategoryTree") ?>",
|
||||
"action": function(node) {
|
||||
if (window.confirm("<?php echo __("Zamierzasz usunąć kategorię z drzewa. Jesteś pewien, że chcesz kontynuować?", null, "stCategoryTree") ?>")) {
|
||||
var tree = this;
|
||||
$(document).trigger("preloader", "show");
|
||||
$.post("<?php echo st_url_for("@stCategory?action=ajaxDelete") ?>", { "id": node.data("id") }, function(response) {
|
||||
$(document).trigger("preloader", "close");
|
||||
|
||||
if (!response.error)
|
||||
{
|
||||
tree.delete_node(node);
|
||||
}
|
||||
else
|
||||
{
|
||||
window.alert(response.error);
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
"_disabled": node.data('is-root'),
|
||||
"separator_after": true,
|
||||
},
|
||||
"edit": {
|
||||
"label": "<?php echo __("Edytuj", null, "stCategoryTree") ?>",
|
||||
"action": function(node) {
|
||||
$(document).trigger("preloader", "show");
|
||||
var location = "<?php echo st_url_for("@stCategory?action=edit&id=__id__") ?>";
|
||||
window.location = location.replace("__id__", node.data("id"));
|
||||
},
|
||||
"submenu": false,
|
||||
},
|
||||
}
|
||||
|
||||
return items;
|
||||
}
|
||||
}
|
||||
}).on("rename_node.jstree", function(e, data) {
|
||||
$(document).trigger("preloader", "show");
|
||||
var node = data.rslt.obj;
|
||||
if (node.data("id")) {
|
||||
$.post("<?php echo st_url_for("@stCategory?action=ajaxRename") ?>", { "id": node.data("id"), "name": data.rslt.name }, function() {
|
||||
$(document).trigger("preloader", "close");
|
||||
});
|
||||
} else {
|
||||
var parent = data.inst._get_parent(node);
|
||||
$.post("<?php echo st_url_for("@stCategory?action=ajaxAdd") ?>", { "parent_id": parent.data("id"), "name": data.rslt.name }, function(response) {
|
||||
node.data("id", response.id);
|
||||
$(document).trigger("preloader", "close");
|
||||
});
|
||||
}
|
||||
}).on("move_node.jstree", function(e, data) {
|
||||
var tree = data.inst;
|
||||
var node = data.rslt.o;
|
||||
var target = data.rslt.r;
|
||||
var type = data.rslt.p;
|
||||
|
||||
var params = { "id": node.data("id") };
|
||||
|
||||
switch (type) {
|
||||
case "after":
|
||||
var next = tree._get_next(node, true);
|
||||
|
||||
if (!next) {
|
||||
var parent = tree._get_parent(target);
|
||||
params.parent_id = parent.data("id");
|
||||
} else {
|
||||
params.sibling_id = next.data("id");
|
||||
}
|
||||
break;
|
||||
|
||||
case "last":
|
||||
params.parent_id = target.data("id");
|
||||
break;
|
||||
|
||||
case "before":
|
||||
params.sibling_id = target.data("id");
|
||||
break;
|
||||
}
|
||||
|
||||
$(document).trigger("preloader", "show");
|
||||
$.post("<?php echo st_url_for("@stCategory?action=ajaxMove") ?>", params, function(response) {
|
||||
$(document).trigger("preloader", "close");
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
jQuery(function($) {
|
||||
$("#category_tree_container .category_tree_action").click(function() {
|
||||
var action = $(this);
|
||||
|
||||
if (action.hasClass("disabled")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (action.data("admin-confirm") && !window.confirm(action.data('admin-confirm'))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!action.data("admin-confirm")) {
|
||||
$(document).trigger("preloader", "show");
|
||||
}
|
||||
|
||||
window.location = action.prop('href');
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<?php st_include_partial("stCategory/footer") ?>
|
||||
Reference in New Issue
Block a user