FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
Coding-iOS/Coding_iOS/Models/ProjectTopic.m at master · fluensh/Coding-iOS · GitHub
fluensh
/
Coding-iOS
Public
forked from
coding/Coding-iOS
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
Coding-iOS
/
Coding_iOS
/
Models
/
ProjectTopic.m
Copy path
More file actions
More file actions
Latest commit
History
History
History
executable file
·
170 lines (149 loc) · 4.58 KB
Breadcrumbs
Coding-iOS
/
Coding_iOS
/
Models
/
ProjectTopic.m
Copy path
File metadata and controls
executable file
·
170 lines (149 loc) · 4.58 KB
Raw
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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
//
//
ProjectTopic.m
//
Coding_iOS
//
//
Created by 王 原闯 on 14-8-20.
//
Copyright (c) 2014年 Coding. All rights reserved.
//
#
import
"
ProjectTopic.h
"
#
import
"
Login.h
"
#
import
"
ProjectTag.h
"
@implementation
ProjectTopic
- (
instancetype
)
init
{
self = [
super
init
];
if
(self) {
_propertyArrayMap = [
NSDictionary
dictionaryWithObjectsAndKeys:
@"
ProjectTag
"
,
@"
labels
"
,
nil
];
_page = [
NSNumber
numberWithInteger:
1
];
_pageSize = [
NSNumber
numberWithInteger:
20
];
_canLoadMore =
YES
;
_isLoading = _willLoadMore =
NO
;
_contentHeight =
1
;
_title =
@"
"
;
_content =
@"
"
;
_mdTitle =
@"
"
;
_mdContent =
@"
"
;
_labels = [[
NSMutableArray
alloc
]
initWithCapacity:
3
];
_mdLabels = [[
NSMutableArray
alloc
]
initWithCapacity:
3
];
}
return
self;
}
- (
void
)
setContent
:
(
NSString
*)
content
{
if
(_content != content) {
_htmlMedia = [HtmlMedia
htmlMediaWithString:
content
showType:
MediaShowTypeCode];
_content = _htmlMedia.
contentDisplay
;
}
}
+ (ProjectTopic *)
feedbackTopic
{
ProjectTopic *topic = [[ProjectTopic
alloc
]
init
];
topic.
project
= [Project
project_FeedBack
];
topic.
project_id
= topic.
project
.
id
;
return
topic;
}
+ (ProjectTopic *)
topicWithPro
:
(Project *)
pro
{
ProjectTopic *topic = [[ProjectTopic
alloc
]
init
];
topic.
owner
= [Login
curLoginUser
];
topic.
project
= pro;
topic.
project_id
= pro.
id
;
return
topic;
}
+ (ProjectTopic *)
topicWithId
:
(
NSNumber
*)
topicId
{
ProjectTopic *topic = [[ProjectTopic
alloc
]
init
];
topic.
id
= topicId;
return
topic;
}
- (
NSString
*)
toTopicPath
{
return
[
NSString
stringWithFormat:
@"
api/topic/
%d
"
,
self
.
id
.intValue];
}
- (
NSDictionary
*)
toEditParams
{
NSMutableArray
*tempAry = [
NSMutableArray
arrayWithCapacity:
_mdLabels.count];
for
(ProjectTag *lbl in _mdLabels) {
[tempAry
addObject:
lbl.
id
];
}
return
@{
@"
title
"
: [_mdTitle
aliasedString
],
@"
content
"
: [_mdContent
aliasedString
],
@"
label
"
: tempAry};
}
- (
NSString
*)
toLabelPath
{
return
[
NSString
stringWithFormat:
@"
api/user/
%@
/project/
%@
/topics/
%d
/labels
"
, _project.owner_user_name, _project.name,
self
.
id
.intValue];
}
- (
NSDictionary
*)
toLabelParams
{
NSMutableArray
*tempAry = [
NSMutableArray
arrayWithCapacity:
_mdLabels.count];
for
(ProjectTag *lbl in _mdLabels) {
[tempAry
addObject:
lbl.
id
];
}
return
@{
@"
label_id
"
: tempAry};
}
- (
NSString
*)
toAddTopicPath
{
return
[
NSString
stringWithFormat:
@"
api/project/
%d
/topic?parent=0
"
, [
self
.project_id
intValue
]];
}
- (
NSDictionary
*)
toAddTopicParams
{
NSMutableArray
*tempAry = [
NSMutableArray
arrayWithCapacity:
_mdLabels.count];
for
(ProjectTag *lbl in _mdLabels) {
[tempAry
addObject:
lbl.
id
];
}
return
@{
@"
title
"
: [_mdTitle
aliasedString
],
@"
content
"
: [_mdContent
aliasedString
],
@"
label
"
: tempAry};
}
- (
NSString
*)
toCommentsPath
{
return
[
NSString
stringWithFormat:
@"
api/topic/
%d
/comments
"
, _id.intValue];
}
- (
NSDictionary
*)
toCommentsParams
{
return
@{
@"
page
"
: (_willLoadMore? [
NSNumber
numberWithInteger:
_page.integerValue +
1
] : [
NSNumber
numberWithInteger:
1
]),
@"
pageSize
"
: _pageSize};
}
- (
void
)
configWithComments
:
(ProjectTopics *)
comments
{
self.
page
= comments.
page
;
self.
totalRow
= comments.
totalRow
;
self.
totalPage
= comments.
totalPage
;
if
(_willLoadMore) {
[_comments.list
addObjectsFromArray:
comments.list];
}
else
{
self.
comments
= comments;
}
_canLoadMore = (_page.
integerValue
< _totalPage.
integerValue
);
}
- (
NSString
*)
toDoCommentPath
{
return
[
NSString
stringWithFormat:
@"
api/project/
%d
/topic?parent=
%d
"
, _project_id.intValue, _id.intValue];
}
- (
NSDictionary
*)
toDoCommentParams
{
return
@{
@"
content
"
: [_nextCommentStr
aliasedString
]};
}
- (
void
)
configWithComment
:
(ProjectTopic *)
comment
{
if
(self.
canLoadMore
) {
return
;
}
if
(self.
comments
&& self.
comments
.
list
) {
[
self
.comments.list
addObject:
comment];
}
else
{
self.
comments
= [[ProjectTopics
alloc
]
init
];
self.
comments
.
list
= [
NSMutableArray
arrayWithObject:
comment];
}
self.
child_count
= [
NSNumber
numberWithInteger:
_child_count.intValue +
1
];
}
- (
NSString
*)
toDeletePath
{
return
[
NSString
stringWithFormat:
@"
api/topic/
%d
"
,
self
.
id
.intValue];
}
- (
BOOL
)
canEdit
{
return
([Login
isLoginUserGlobalKey:
self
.owner.global_key] ||
//
讨论创建者
[Login
isLoginUserGlobalKey:
self
.project.owner_user_name]);
//
项目创建者
}
@end
Back
|
FazBrowse Home
|
New Git URL