Page Menu
Home
Sealhub
Search
Configure Global Search
Log In
Files
F10360278
resource-list.jsx
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
resource-list.jsx
View Options
var
React
=
require
(
"react"
);
var
rest
=
require
(
"qwest"
);
var
merge
=
require
(
"merge"
);
var
type_collection
=
require
(
"./resource-type-collection.mixin.jsx"
);
var
Pagination
=
require
(
"./resource-list-pagination.jsx"
);
var
Loading
=
require
(
"../components/loading.jsx"
);
var
ResourceList
=
React
.
createClass
({
mixins
:
[
type_collection
],
getDefaultProps
()
{
return
{
containerComponent
:
"ul"
,
className
:
""
,
};
},
getInitialState
:
function
()
{
return
{
page
:
1
,
};
},
wrap
:
function
(
method
,
resource
){
return
method
.
bind
(
this
,
resource
);
},
nextPage
:
function
(){
this
.
setState
({
pagination
:
merge
(
this
.
state
.
pagination
,
{
page
:
this
.
state
.
pagination
.
page
+
1
})
});
this
.
refresh
();
},
prevPage
:
function
(){
this
.
setState
({
pagination
:
merge
(
this
.
state
.
pagination
,
{
page
:
this
.
state
.
pagination
.
page
-
1
})
});
this
.
refresh
();
},
render
:
function
(){
var
self
=
this
;
var
list_elements
=
this
.
state
.
resources
.
map
(
function
(
resource
,
index
){
return
React
.
createElement
(
self
.
props
.
listElementClass
,
{
resource
:
resource
,
index
:
index
,
key
:
resource
.
id
,
onDelete
:
self
.
wrap
(
self
.
delete
,
resource
),
afterChange
:
self
.
refresh
});
});
var
pagination
=
<
Pagination
hasPrev
=
{
this
.
state
.
pagination
.
page
!=
1
}
hasNext
=
{
this
.
state
.
resources
.
length
==
12
}
onPrev
=
{
this
.
prevPage
}
onNext
=
{
this
.
nextPage
}
/>
if
(
this
.
state
.
loading
){
return
<
Loading
/>
}
else
if
(
list_elements
.
length
){
return
(
<
div
className
=
{
this
.
props
.
className
}
>
{
pagination
}
{
React
.
createElement
(
this
.
props
.
containerComponent
,
{
className
:
"resource-list"
},
list_elements
)}
{
pagination
}
<
/div>
)
}
else
if
(
self
.
props
.
emptyClass
){
return
<
div
>
{
pagination
}
{
React
.
createElement
(
self
.
props
.
emptyClass
)}
<
/div>
}
else
{
return
<
div
>
{
pagination
}
<
/div>
}
}
})
module
.
exports
=
ResourceList
;
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Nov 8, 06:10 (1 d, 6 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1032114
Default Alt Text
resource-list.jsx (1 KB)
Attached To
Mode
rTG Typing Golf
Attached
Detach File
Event Timeline
Log In to Comment