Skip to content

Commit 7d880ac

Browse files
committed
Patch-B
1 parent 1a81b9b commit 7d880ac

File tree

47 files changed

+1473
-263
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+1473
-263
lines changed
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<?import javafx.scene.text.*?>
4+
<?import javafx.scene.control.*?>
5+
<?import javafx.scene.image.*?>
6+
<?import javafx.geometry.*?>
7+
<?import java.lang.*?>
8+
<?import javafx.scene.layout.*?>
9+
10+
11+
<AnchorPane maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" minHeight="-Infinity" minWidth="-Infinity" styleClass="dn-web" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1">
12+
<children>
13+
<VBox maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" spacing="10.0" styleClass="dn-web" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
14+
<padding>
15+
<Insets bottom="15.0" left="15.0" right="15.0" top="15.0" />
16+
</padding>
17+
<children>
18+
<HBox alignment="CENTER_LEFT" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" minWidth="600.0" spacing="10.0">
19+
<children>
20+
<ImageView id="categoryIcon" fitHeight="32.0" fitWidth="32.0" pickOnBounds="true" preserveRatio="true" />
21+
<VBox spacing="2.0" HBox.hgrow="ALWAYS">
22+
<children>
23+
<Label id="categoryNameLabel" text="CategoryName">
24+
<font>
25+
<Font name="System Bold" size="15.0" />
26+
</font>
27+
</Label>
28+
<Label id="categoryDescriptionLabel" text="CategoryDescription" textFill="#909090" />
29+
</children>
30+
</VBox>
31+
<HBox prefHeight="40.0" prefWidth="311.0" spacing="8.0">
32+
<children>
33+
<Button id="searchButton" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" mnemonicParsing="false" prefWidth="40.0">
34+
<styleClass>
35+
<String fx:value="flat-button" />
36+
<String fx:value="icon-flat-search" />
37+
</styleClass>
38+
</Button>
39+
<TextField id="searchField" maxHeight="1.7976931348623157E308" prefHeight="40.0" promptText="Поиск" HBox.hgrow="ALWAYS">
40+
<font>
41+
<Font size="17.0" />
42+
</font>
43+
</TextField>
44+
</children>
45+
</HBox>
46+
</children>
47+
</HBox>
48+
<Separator maxWidth="1.7976931348623157E308" prefHeight="2.0" prefWidth="419.0" />
49+
<HBox id="moderPane" prefHeight="30.0" prefWidth="200.0" spacing="10.0">
50+
<children>
51+
<Button id="addEntryButton" maxHeight="1.7976931348623157E308" mnemonicParsing="false" styleClass="icon-plus" text="Добавить статью">
52+
<padding>
53+
<Insets left="15.0" right="15.0" />
54+
</padding>
55+
</Button>
56+
</children>
57+
</HBox>
58+
<VBox id="categoryContent" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" minHeight="70.0" VBox.vgrow="ALWAYS" />
59+
</children>
60+
</VBox>
61+
</children>
62+
</AnchorPane>

develnext-doc/src/ide/doc/account/api/DocService.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
* Class DocService
1414
* @package ide\doc\account\api
1515
*
16+
* @method ServiceResponseFuture accessInfoAsync(callable $callback = null)
1617
* @method ServiceResponseFuture categoryTreeAsync(callable $callback = null)
1718
* @method ServiceResponseFuture categoryAsync($id, callable $callback = null)
1819
* @method ServiceResponseFuture categoriesAsync($parentCategoryId, callable $callback = null)
@@ -29,6 +30,11 @@
2930
*/
3031
class DocService extends AbstractService
3132
{
33+
public function accessInfo()
34+
{
35+
return $this->execute('doc/access-info', []);
36+
}
37+
3238
/**
3339
* Return full tree of categories.
3440
*/
@@ -76,7 +82,7 @@ public function entries($categoryId, $offset = 0, $limit = 40)
7682

7783
public function allEntries($sort = 'UPDATED_AT', $offset = 0, $limit = 40)
7884
{
79-
return $this->execute('doc/entries', ['categoryId' => $sort, 'offset' => $offset, 'limit' => $limit]);
85+
return $this->execute('doc/entries', ['sort' => $sort, 'offset' => $offset, 'limit' => $limit]);
8086
}
8187

8288
public function saveEntry($data)

develnext-doc/src/ide/doc/editors/DocEditor.php

Lines changed: 122 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,12 @@
99
use ide\doc\editors\commands\EditCategoryMenuCommand;
1010
use ide\editors\AbstractEditor;
1111
use ide\editors\menu\ContextMenu;
12+
use ide\forms\area\DocEntryListArea;
1213
use ide\Ide;
14+
use ide\ui\Notifications;
1315
use ide\utils\Tree;
1416
use php\gui\layout\UXAnchorPane;
17+
use php\gui\layout\UXScrollPane;
1518
use php\gui\UXListView;
1619
use php\gui\UXNode;
1720
use php\gui\UXTreeItem;
@@ -35,7 +38,7 @@ public function __construct(array $data)
3538

3639
public function __toString()
3740
{
38-
return (string) $this->data['name'];
41+
return (string)$this->data['name'];
3942
}
4043

4144
/**
@@ -70,7 +73,7 @@ class DocEditor extends AbstractEditor
7073
protected $uiTreeMenu;
7174

7275
/**
73-
* @var UXNode
76+
* @var DocEntryListArea
7477
*/
7578
protected $ui;
7679

@@ -84,8 +87,26 @@ class DocEditor extends AbstractEditor
8487
*/
8588
protected $expandedItems;
8689

90+
/**
91+
* @var bool
92+
*/
8793
protected $treeLoaded = false;
8894

95+
/**
96+
* @var null
97+
*/
98+
protected $loadedCategoryId = -1;
99+
100+
/**
101+
* @var bool
102+
*/
103+
protected $accessCategory = false;
104+
105+
/**
106+
* @var bool
107+
*/
108+
protected $accessEntry = false;
109+
89110
/**
90111
* DocEditor constructor.
91112
* @param string $file
@@ -132,9 +153,59 @@ public function refreshTree()
132153

133154
protected function loadContent()
134155
{
135-
$this->docService->allEntriesAsync('UPDATED_AT', 0, 50, function () {
156+
$item = $this->uiTree->focusedItem;
136157

158+
$this->docService->accessInfoAsync(function (ServiceResponse $response) {
159+
if ($response->isSuccess()) {
160+
$this->accessCategory = $response->data()['category'];
161+
$this->accessEntry = $response->data()['entry'];
162+
$this->ui->setAccess($this->accessCategory, $this->accessEntry);
163+
}
137164
});
165+
166+
$this->ui->setContent([
167+
'name' => 'Документация',
168+
'description' => 'Добро пожаловать в справочную систему по DevelNext'
169+
], []);
170+
171+
172+
if ($item->value instanceof DocEditorTreeItem) {
173+
$category = $item->value->getData();
174+
$this->ui->setContent($category, []);
175+
176+
if ($category['id'] == $this->loadedCategoryId) {
177+
return;
178+
}
179+
180+
$this->ui->showPreloader();
181+
$this->docService->entriesAsync($category['id'], 0, 40, function (ServiceResponse $response) use ($item, $category) {
182+
$this->ui->setAccess($this->accessCategory, $this->accessEntry);
183+
if ($response->isSuccess()) {
184+
$this->ui->setContent($item->value->getData(), $response->data());
185+
}
186+
187+
$this->ui->hidePreloader();
188+
$this->loadedCategoryId = $category['id'];
189+
});
190+
} else {
191+
if (null == $this->loadedCategoryId) {
192+
return;
193+
}
194+
195+
$this->ui->showPreloader();
196+
$this->docService->allEntriesAsync('UPDATED_AT', 0, 50, function (ServiceResponse $response) {
197+
if ($response->isSuccess()) {
198+
$this->ui->setContent([
199+
'name' => 'Документация',
200+
'description' => 'Добро пожаловать в справочную систему по DevelNext'
201+
], $response->data());
202+
}
203+
204+
$this->ui->hidePreloader();
205+
$this->loadedCategoryId = null;
206+
$this->ui->setAccess($this->accessCategory, $this->accessEntry);
207+
});
208+
}
138209
}
139210

140211
protected function getTreeExpandedItems()
@@ -196,6 +267,8 @@ public function setSelectedCategory(array $data = null)
196267
$this->uiTree->focusedItem = $this->uiTree->root;
197268
$this->uiTree->selectedItems = [$this->uiTree->root];
198269
}
270+
271+
$this->loadContent();
199272
}
200273

201274
public function open()
@@ -218,17 +291,37 @@ public function save()
218291
Ide::get()->setUserConfigValue(__CLASS__ . '#treeExpandedItems', $this->getTreeExpandedItems());
219292
}
220293

294+
public function addEntry($name)
295+
{
296+
$category = $this->getSelectedCategory();
297+
298+
$this->docService->saveEntryAsync([
299+
'name' => $name,
300+
'categoryId' => $category['id'],
301+
], function (ServiceResponse $response) {
302+
if ($response->isNotSuccess()) {
303+
Notifications::error('Ошибка', $response->message());
304+
return;
305+
}
306+
307+
$this->loadContent();
308+
});
309+
}
310+
221311
/**
222312
* @return UXNode
223313
*/
224314
public function makeUi()
225315
{
226-
$list = new UXListView();
227-
UXAnchorPane::setAnchor($list, 10);
228-
229-
$this->uiList = $list;
230-
231-
return $list;
316+
$ui = new DocEntryListArea();
317+
$ui->on('addEntry', [$this, 'addEntry']);
318+
UXAnchorPane::setAnchor($ui, 0);
319+
320+
$this->ui = $ui;
321+
$pane = new UXScrollPane($ui);
322+
$pane->fitToWidth = true;
323+
$pane->classes->add('dn-web');
324+
return $pane;
232325
}
233326

234327
public function makeLeftPaneUi()
@@ -240,6 +333,10 @@ public function makeLeftPaneUi()
240333
$tree->root->graphic = Ide::get()->getImage($this->getIcon());
241334
$tree->multipleSelection = false;
242335

336+
$tree->on('mouseUp', function () {
337+
$this->loadContent();
338+
});
339+
243340
UXAnchorPane::setAnchor($tree, 0);
244341

245342
$this->uiTree = $tree;
@@ -254,4 +351,20 @@ public function makeLeftPaneUi()
254351

255352
return $tree;
256353
}
354+
355+
/**
356+
* @return boolean
357+
*/
358+
public function isAccessCategory()
359+
{
360+
return $this->accessCategory;
361+
}
362+
363+
/**
364+
* @return boolean
365+
*/
366+
public function isAccessEntry()
367+
{
368+
return $this->accessEntry;
369+
}
257370
}

develnext-doc/src/ide/doc/editors/commands/AddCategoryMenuCommand.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use ide\editors\menu\AbstractMenuCommand;
88
use ide\ui\Notifications;
99
use php\gui\UXDialog;
10+
use php\gui\UXMenuItem;
1011

1112
class AddCategoryMenuCommand extends AbstractMenuCommand
1213
{
@@ -23,7 +24,6 @@ public function getIcon()
2324
public function onExecute($e = null, AbstractEditor $editor = null)
2425
{
2526
if ($editor instanceof DocEditor) {
26-
2727
$name = UXDialog::input('Название категории');
2828

2929
if ($name !== null) {
@@ -41,4 +41,11 @@ function (ServiceResponse $response) use ($editor) {
4141
}
4242
}
4343
}
44+
45+
public function onBeforeShow(UXMenuItem $item, AbstractEditor $editor = null)
46+
{
47+
if ($editor instanceof DocEditor) {
48+
$item->visible = $editor->isAccessCategory();
49+
}
50+
}
4451
}

develnext-doc/src/ide/doc/editors/commands/AddSubCategoryMenuCommand.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@ public function onBeforeShow(UXMenuItem $item, AbstractEditor $editor = null)
5656
} else {
5757
$item->text = $this->getName();
5858
}
59+
60+
if ($item->visible) {
61+
$item->visible = $editor->isAccessCategory();
62+
}
5963
}
6064
}
6165
}

develnext-doc/src/ide/doc/editors/commands/DeleteCategoryMenuCommand.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ public function onBeforeShow(UXMenuItem $item, AbstractEditor $editor = null)
4848
{
4949
if ($editor instanceof DocEditor) {
5050
$item->disable = !$editor->getSelectedCategory();
51+
$item->visible = $editor->isAccessCategory();
5152
}
5253
}
5354
}

develnext-doc/src/ide/doc/editors/commands/EditCategoryMenuCommand.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ public function onBeforeShow(UXMenuItem $item, AbstractEditor $editor = null)
2929
{
3030
if ($editor instanceof DocEditor) {
3131
$item->disable = !$editor->getSelectedCategory();
32+
$item->visible = $editor->isAccessCategory();
3233
}
3334
}
3435
}

0 commit comments

Comments
 (0)