Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
146 lines (130 loc) · 3.63 KB

File metadata and controls

146 lines (130 loc) · 3.63 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
//
// EAWiki.m
// Coding_Enterprise_iOS
//
// Created by Ease on 2017/4/5.
// Copyright © 2017年 Coding. All rights reserved.
//
#define kEAWiki_MaxLevel 3
#import "EAWiki.h"
@interface EAWiki ()
@property (readwrite, strong, nonatomic) EAWiki *parentWiki;
@property (readwrite, nonatomic, strong) NSArray *childrenDisplayList;
@end
@implementation EAWiki
- (instancetype)init{
self = [super init];
if (self) {
_isExpanded = YES;
_parentWiki = nil;
}
return self;
}
- (NSDictionary *)propertyArrayMap{
return @{@"children": @"EAWiki"};
}
- (void)setChildren:(NSArray *)children{
_children = children;
for (EAWiki *wiki in _children) {
wiki.parentWiki = self;
}
}
- (NSInteger)lavel{
NSInteger lavel = 0;
EAWiki *tempWiki = self;
while (tempWiki.parentWiki) {
tempWiki = tempWiki.parentWiki;
lavel += 1;
}
// return lavel;
return MIN(lavel, kEAWiki_MaxLevel);
}
- (BOOL)isHistoryVersion{
return _currentVersion.integerValue < _lastVersion.integerValue;
}
- (BOOL)hasChildren{
return self.childrenDisplayList.count > 0;
}
- (NSString *)mdTitle{
if (!_mdTitle) {
_mdTitle = _title.copy;
}
return _mdTitle;
}
- (NSString *)mdContent{
if (!_mdContent) {
_mdContent = _content.copy;
}
return _mdContent;
}
- (NSArray *)childrenDisplayList{
// return _children;
if (self.lavel < kEAWiki_MaxLevel - 1) {
return _children;
}else
if (!_childrenDisplayList) {
if (self.lavel < kEAWiki_MaxLevel - 1) {
_childrenDisplayList = _children.copy;
}else if (self.lavel == kEAWiki_MaxLevel - 1){
_childrenDisplayList = [self allChildren].copy;
}else{
_childrenDisplayList = @[];
}
}
return _childrenDisplayList;
}
- (NSArray *)allChildren{
NSMutableArray *list = _children? _children.mutableCopy: @[].mutableCopy;
for (EAWiki *wiki in _children) {
NSArray *childrenList = [wiki allChildren];
NSUInteger loc = [list indexOfObject:wiki];
if (childrenList.count > 0 && loc != NSNotFound) {
[list insertObjects:childrenList atIndexes:[NSIndexSet indexSetWithIndexesInRange:NSMakeRange(loc + 1, childrenList.count)]];
}
}
return list;
}
- (BOOL)hasDraft{
NSDictionary *data = [NSObject loadResponseWithPath:[self p_draftPath]];
return data != nil;
}
- (BOOL)draftVersionChanged{
NSDictionary *data = [NSObject loadResponseWithPath:[self p_draftPath]];
NSNumber *draftVersion = data[@"draftVersion"];
if (draftVersion.integerValue < _currentVersion.integerValue) {
return YES;
}
return NO;
}
- (BOOL)hasChanged{
return ![_mdTitle isEqualToString:_title] || ![_mdContent isEqualToString:_content];
}
- (void)saveDraft{
[NSObject saveResponseData:[self p_draftData] toPath:[self p_draftPath]];
}
- (void)readDraft{
NSDictionary *data = [NSObject loadResponseWithPath:[self p_draftPath]];
self.mdTitle = data[@"mdTitle"];
self.mdContent = data[@"mdContent"];
self.draftVersion = data[@"draftVersion"];
}
- (void)deleteDraft{
[NSObject deleteResponseCacheForPath:[self p_draftPath]];
}
- (NSString *)p_draftPath{
return [NSString stringWithFormat:@"wiki_%@", _id];
}
- (NSDictionary *)p_draftData{
return @{@"mdTitle": _mdTitle ?: @"",
@"mdContent": _mdContent ?: @"",
@"draftVersion": _currentVersion ?: @0};
}
- (NSDictionary *)toShareParams{
return @{
@"projectId": _project_id,
@"resourceId": _iid,
@"resourceType": @2,
@"accessType": @0
};
}
@end
Morty Proxy This is a proxified and sanitized view of the page, visit original site.