зеркало из https://github.com/nextcloud/approval.git
adjust approve/reject to multiple settings in backend
Signed-off-by: Julien Veyssier <eneiluj@posteo.net>
This commit is contained in:
Родитель
9c16da1b18
Коммит
c68548813d
|
@ -88,7 +88,7 @@ class ApprovalController extends Controller {
|
|||
* @return DataDisplayResponse
|
||||
*/
|
||||
public function approve(int $fileId): DataResponse {
|
||||
$this->approvalService->approve($fileId);
|
||||
$this->approvalService->approve($fileId, $this->userId);
|
||||
return new DataResponse(1);
|
||||
}
|
||||
|
||||
|
@ -101,7 +101,7 @@ class ApprovalController extends Controller {
|
|||
* @return DataDisplayResponse
|
||||
*/
|
||||
public function reject(int $fileId): DataResponse {
|
||||
$this->approvalService->reject($fileId);
|
||||
$this->approvalService->reject($fileId, $this->userId);
|
||||
return new DataResponse(1);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -97,35 +97,41 @@ class ApprovalService {
|
|||
|
||||
/**
|
||||
* @param int $fileId
|
||||
* @return void
|
||||
* @return bool success
|
||||
*/
|
||||
public function approve(int $fileId): void {
|
||||
$tagApprovedId = (int) $this->config->getAppValue(Application::APP_ID, 'tag_approved', '0');
|
||||
$this->tagObjectMapper->assignTags($fileId, 'files', $tagApprovedId);
|
||||
|
||||
$tagPendingId = (int) $this->config->getAppValue(Application::APP_ID, 'tag_pending', '0');
|
||||
try {
|
||||
if ($this->tagObjectMapper->haveTag($fileId, 'files', $tagPendingId)) {
|
||||
$this->tagObjectMapper->unassignTags($fileId, 'files', $tagPendingId);
|
||||
public function approve(int $fileId, ?string $userId): bool {
|
||||
$settings = $this->settingService->getSettings();
|
||||
foreach ($settings as $id => $setting) {
|
||||
try {
|
||||
if ($this->tagObjectMapper->haveTag($fileId, 'files', $setting['tagPending'])
|
||||
&& in_array($userId, $setting['users'])) {
|
||||
$this->tagObjectMapper->assignTags($fileId, 'files', $setting['tagApproved']);
|
||||
$this->tagObjectMapper->unassignTags($fileId, 'files', $setting['tagPending']);
|
||||
return true;
|
||||
}
|
||||
} catch (TagNotFoundException $e) {
|
||||
}
|
||||
} catch (TagNotFoundException $e) {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $fileId
|
||||
* @return void
|
||||
* @return bool success
|
||||
*/
|
||||
public function reject(int $fileId): void {
|
||||
$tagRejectedId = (int) $this->config->getAppValue(Application::APP_ID, 'tag_rejected', '0');
|
||||
$this->tagObjectMapper->assignTags($fileId, 'files', $tagRejectedId);
|
||||
|
||||
$tagPendingId = (int) $this->config->getAppValue(Application::APP_ID, 'tag_pending', '0');
|
||||
try {
|
||||
if ($this->tagObjectMapper->haveTag($fileId, 'files', $tagPendingId)) {
|
||||
$this->tagObjectMapper->unassignTags($fileId, 'files', $tagPendingId);
|
||||
public function reject(int $fileId, ?string $userId): bool {
|
||||
$settings = $this->settingService->getSettings();
|
||||
foreach ($settings as $id => $setting) {
|
||||
try {
|
||||
if ($this->tagObjectMapper->haveTag($fileId, 'files', $setting['tagPending'])
|
||||
&& in_array($userId, $setting['users'])) {
|
||||
$this->tagObjectMapper->assignTags($fileId, 'files', $setting['tagRejected']);
|
||||
$this->tagObjectMapper->unassignTags($fileId, 'files', $setting['tagPending']);
|
||||
return true;
|
||||
}
|
||||
} catch (TagNotFoundException $e) {
|
||||
}
|
||||
} catch (TagNotFoundException $e) {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -144,7 +144,9 @@ export default {
|
|||
|
||||
methods: {
|
||||
update(key, value) {
|
||||
this.$emit('input', { ...this.value, [key]: value })
|
||||
if (value) {
|
||||
this.$emit('input', { ...this.value, [key]: value })
|
||||
}
|
||||
},
|
||||
asyncFind(query) {
|
||||
this.query = query
|
||||
|
|
Загрузка…
Ссылка в новой задаче