Commit e078f379 authored by Matija Obreza's avatar Matija Obreza

Applying _permissions to objects and displaying Edit button when _permissions.write===true

parent 2dc8a241
Pipeline #3691 passed with stages
in 4 minutes and 13 seconds
......@@ -50,7 +50,7 @@ const styles = (theme) => ({
title: {
fontWeight: 'bold' as 'bold',
fontSize: '1rem',
color: '#006db4',
/*color: '#006db4',*/
},
footer: {
height: '30px',
......@@ -100,18 +100,30 @@ class DataTable extends React.Component<IDataTableProps, any> {
<TableCell className={ `${ classes.tableCell } ${ classes.fake }` } padding="none"/>
<TableCell className={ `${ classes.tableCell } ${ classes.numeration }` }>{ i + 1 }</TableCell>
<TableCell className={ `${ classes.tableCell } ${ classes.title }` }>
{ e.published && (
<Link to={ `${path}/${e.uuid}` }>
{ e.title }
</Link>
) }
{ ! e.published && e.title }
</TableCell>
<TableCell className={ `${ classes.tableCell } ${ classes.creationDate }` }>{ e.createdDate && moment(e.createdDate).format('YYYY-DD-MM h:mm') }</TableCell>
{ showStatus && <TableCell className={ `${ classes.tableCell }` }>{ e.published ? 'published' : 'ongoing' }</TableCell> }
<TableCell className={ `${ classes.tableCell } ${ classes.edit }` }>
{ ! e.published && e._permissions && e._permissions.write && (
<Link to={ `${path}/${e.uuid}/edit` }>
<Button raised className={ classes.btnEdit }>
EDIT
</Button>
</Link>
) }
{ e.published && (
<Link to={ `${path}/${e.uuid}` }>
<Button raised className={ classes.btnEdit }>
VIEW
</Button>
</Link>
) }
</TableCell>
<TableCell className={ `${ classes.tableCell } ${ classes.fake }` } padding="none"/>
</TableRow>
......
......@@ -144,3 +144,21 @@ export class DataOrder {
return other !== null && other !== undefined && other.direction === this.direction && arraysEqual(other.sort, this.sort);
}
}
export class CurrentPermissions extends EmptyModel {
public create: boolean;
public read: boolean;
public write: boolean;
public delete: boolean;
public manage: boolean;
public constructor(obj?) {
if (obj) {
super(obj);
}
}
}
export interface IUserPermissions {
_permissions: CurrentPermissions;
}
import {EmptyModel, UuidModel} from './common.model';
import {EmptyModel, UuidModel, CurrentPermissions, IUserPermissions} from './common.model';
import {RepositoryFile} from './repositoryFile.model';
import {Location} from './location.model';
import {Partner} from './partner.model';
......@@ -19,7 +19,7 @@ class AccessionIdentifier extends EmptyModel {
}
}
class Dataset extends UuidModel {
class Dataset extends UuidModel implements IUserPermissions {
public title: string;
public description: string;
public rights: string;
......@@ -35,8 +35,13 @@ class Dataset extends UuidModel {
public accessionCount: number;
public descriptorCount: number;
public _permissions: CurrentPermissions;
public constructor(obj?) {
super(obj);
if (obj && obj._permissions) {
this._permissions = new CurrentPermissions(obj._permissions);
}
}
public getClassname(): string {
......
import { UuidModel } from './common.model';
import { UuidModel, CurrentPermissions, IUserPermissions } from './common.model';
import { Partner } from './partner.model';
class Descriptor extends UuidModel {
class Descriptor extends UuidModel implements IUserPermissions {
public crop: string;
public category: string;
public title: string;
......@@ -16,9 +16,13 @@ class Descriptor extends UuidModel {
public uom: string;
public bibliographicCitation: string;
public owner: Partner;
public _permissions: CurrentPermissions;
public constructor(obj?) {
super(obj);
if (obj && obj._permissions) {
this._permissions = new CurrentPermissions(obj._permissions);
}
}
public getClassname(): string {
......@@ -26,7 +30,7 @@ class Descriptor extends UuidModel {
}
}
class DescriptorList extends UuidModel {
class DescriptorList extends UuidModel implements IUserPermissions {
public crop: string;
public title: string;
public description: string;
......@@ -42,9 +46,13 @@ class DescriptorList extends UuidModel {
public uom: string;
public publisher: string;
public bibliographicCitation: string;
public _permissions: CurrentPermissions;
public constructor(obj?) {
super(obj);
if (obj && obj._permissions) {
this._permissions = new CurrentPermissions(obj._permissions);
}
}
public getClassname(): string {
......
import { UuidModel } from './common.model';
import { UuidModel, CurrentPermissions, IUserPermissions } from './common.model';
class Partner extends UuidModel {
class Partner extends UuidModel implements IUserPermissions {
public name: string;
public shortName: string;
public description: string;
public wiewsCodes: string[];
public _permissions: CurrentPermissions;
public constructor(obj?) {
super(obj);
if (obj && obj._permissions) {
this._permissions = new CurrentPermissions(obj._permissions);
}
}
public getClassname(): string {
......
{
"extends": [
"tslint:latest",
"tslint-react"
],
"rules": {
"indent": [
false,
"tabs"
],
"quotemark": [
true,
"single",
"jsx-double"
],
"no-var-requires": false,
"ordered-imports": false,
"member-ordering": [
false
],
"max-line-length": [
true, 250
],
"object-literal-sort-keys": false,
"no-shadowed-variable": false,
"no-console": [
false
],
"jsx-alignment": [
false
],
"jsx-boolean-value": [
true,
"never"
],
"jsx-curly-spacing": [
true,
"always"
],
"max-classes-per-file": [true, 10],
"jsx-wrap-multiline": true,
"jsx-no-multiline-js": false
}
"extends": [
"tslint:latest",
"tslint-react"
],
"rules": {
"indent": [
false,
"tabs"
],
"quotemark": [
true,
"single",
"jsx-double"
],
"no-var-requires": false,
"ordered-imports": false,
"member-ordering": [
false
],
"max-line-length": [
true, 250
],
"object-literal-sort-keys": false,
"no-shadowed-variable": false,
"no-console": [
false
],
"jsx-alignment": [
false
],
"jsx-boolean-value": [
true,
"never"
],
"jsx-curly-spacing": [
true,
"always"
],
"max-classes-per-file": [true, 10],
"jsx-wrap-multiline": true,
"jsx-no-multiline-js": false,
"variable-name": [true, "ban-keywords", "allow-leading-underscore"]
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment