Tooltip & Colors
This commit is contained in:
parent
d80de63765
commit
73d20b4b5c
@ -26,6 +26,7 @@ namespace Api\Groups {
|
|||||||
use Api\GroupsAPI;
|
use Api\GroupsAPI;
|
||||||
use Api\Parameter\Parameter;
|
use Api\Parameter\Parameter;
|
||||||
use Api\Parameter\StringType;
|
use Api\Parameter\StringType;
|
||||||
|
use Driver\SQL\Condition\Compare;
|
||||||
|
|
||||||
class Fetch extends GroupsAPI {
|
class Fetch extends GroupsAPI {
|
||||||
|
|
||||||
@ -159,4 +160,41 @@ namespace Api\Groups {
|
|||||||
return $this->success;
|
return $this->success;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class Delete extends GroupsAPI {
|
||||||
|
public function __construct($user, $externalCall = false) {
|
||||||
|
parent::__construct($user, $externalCall, array(
|
||||||
|
'uid' => new Parameter('uid', Parameter::TYPE_INT)
|
||||||
|
));
|
||||||
|
|
||||||
|
$this->loginRequired = true;
|
||||||
|
$this->requiredGroup = array(USER_GROUP_ADMIN);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function execute($values = array()) {
|
||||||
|
if (!parent::execute($values)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$id = $this->getParam("uid");
|
||||||
|
$sql = $this->user->getSQL();
|
||||||
|
|
||||||
|
$res = $sql->select($sql->count())
|
||||||
|
->from("Group")
|
||||||
|
->where(new Compare("uid", $id))
|
||||||
|
->execute();
|
||||||
|
|
||||||
|
$this->success = ($res !== FALSE);
|
||||||
|
$this->lastError = $sql->getLastError();
|
||||||
|
|
||||||
|
if ($this->success && $res[0]["count"] === 0) {
|
||||||
|
return $this->createError("This group does not exist.");
|
||||||
|
}
|
||||||
|
|
||||||
|
$res = $sql->delete("Group")->where(new Compare("uid", $id))->execute();
|
||||||
|
$this->success = ($res !== FALSE);
|
||||||
|
$this->lastError = $sql->getLastError();
|
||||||
|
return $this->success;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
6
js/admin.min.js
vendored
6
js/admin.min.js
vendored
File diff suppressed because one or more lines are too long
@ -86,4 +86,8 @@ export default class API {
|
|||||||
async createGroup(name, color) {
|
async createGroup(name, color) {
|
||||||
return this.apiCall("groups/create", { name: name, color: color });
|
return this.apiCall("groups/create", { name: name, color: color });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async deleteGroup(id) {
|
||||||
|
return this.apiCall("groups/delete", { uid: id });
|
||||||
|
}
|
||||||
};
|
};
|
@ -11,8 +11,12 @@ export default function Dialog(props) {
|
|||||||
|
|
||||||
let buttons = [];
|
let buttons = [];
|
||||||
for (let name of options) {
|
for (let name of options) {
|
||||||
|
let type = "default";
|
||||||
|
if (name === "Yes") type = "warning";
|
||||||
|
else if(name === "No") type = "danger";
|
||||||
|
|
||||||
buttons.push(
|
buttons.push(
|
||||||
<button type="button" key={"button-" + name} className="btn btn-default" data-dismiss={"modal"} onClick={() => { onClose(); onOption(name); }}>
|
<button type="button" key={"button-" + name} className={"btn btn-" + type} data-dismiss={"modal"} onClick={() => { onClose(); onOption(name); }}>
|
||||||
{name}
|
{name}
|
||||||
</button>
|
</button>
|
||||||
)
|
)
|
||||||
|
@ -243,7 +243,7 @@ export default class UserOverview extends React.Component {
|
|||||||
<th>Email</th>
|
<th>Email</th>
|
||||||
<th>Groups</th>
|
<th>Groups</th>
|
||||||
<th>Registered</th>
|
<th>Registered</th>
|
||||||
<th/>
|
<th><Icon icon={"tools"} /></th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
@ -294,6 +294,12 @@ export default class UserOverview extends React.Component {
|
|||||||
{group.color}
|
{group.color}
|
||||||
</span>
|
</span>
|
||||||
</td>
|
</td>
|
||||||
|
<td>
|
||||||
|
<Icon icon={"trash"} style={{color: "red", cursor: "pointer"}}
|
||||||
|
onClick={(e) => this.onDeleteGroup(e, uid)} data-effect={"solid"}
|
||||||
|
data-tip={"Delete"} data-type={"error"}
|
||||||
|
data-place={"bottom"}/>
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -304,6 +310,7 @@ export default class UserOverview extends React.Component {
|
|||||||
<td> </td>
|
<td> </td>
|
||||||
<td/>
|
<td/>
|
||||||
<td/>
|
<td/>
|
||||||
|
<td/>
|
||||||
</tr>
|
</tr>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -342,6 +349,7 @@ export default class UserOverview extends React.Component {
|
|||||||
<th>Name</th>
|
<th>Name</th>
|
||||||
<th className={"text-center"}>Members</th>
|
<th className={"text-center"}>Members</th>
|
||||||
<th>Color</th>
|
<th>Color</th>
|
||||||
|
<th><Icon icon={"tools"} /></th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
@ -373,4 +381,25 @@ export default class UserOverview extends React.Component {
|
|||||||
</div>
|
</div>
|
||||||
</div>;
|
</div>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onDeleteGroup(e, uid) {
|
||||||
|
e.stopPropagation();
|
||||||
|
this.parent.showDialog("Are you really sure you want to delete this group?", "Delete Group?", ["Yes", "No"], (btn) => {
|
||||||
|
if (btn === "Yes") {
|
||||||
|
this.parent.api.deleteGroup(uid).then((res) => {
|
||||||
|
if (!res.success) {
|
||||||
|
let errors = this.state.errors.slice();
|
||||||
|
errors.push({title: "Error deleting group", message: res.msg});
|
||||||
|
this.setState({
|
||||||
|
...this.state,
|
||||||
|
errors: errors
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
this.setState({ ...this.state, loaded: false });
|
||||||
|
this.fetchGroups();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user