* @brief Delete an action by id */
| 2639 | * @brief Delete an action by id |
| 2640 | */ |
| 2641 | API::CommandResponse API::Handlers::ProjectHandler::actionDelete(const QString& id, |
| 2642 | const QJsonObject& params) |
| 2643 | { |
| 2644 | if (!params.contains(QStringLiteral("actionId"))) |
| 2645 | return CommandResponse::makeError( |
| 2646 | id, ErrorCode::MissingParam, QStringLiteral("Missing required parameter: actionId")); |
| 2647 | |
| 2648 | const int actionId = params.value(QStringLiteral("actionId")).toInt(); |
| 2649 | auto& project = DataModel::ProjectModel::instance(); |
| 2650 | const auto& actions = project.actions(); |
| 2651 | if (actionId < 0 || static_cast<size_t>(actionId) >= actions.size()) |
| 2652 | return CommandResponse::makeError( |
| 2653 | id, ErrorCode::InvalidParam, QStringLiteral("Action id not found: %1").arg(actionId)); |
| 2654 | |
| 2655 | project.deleteAction(actionId); |
| 2656 | |
| 2657 | QJsonObject result; |
| 2658 | result[QStringLiteral("actionId")] = actionId; |
| 2659 | result[QStringLiteral("deleted")] = true; |
| 2660 | return CommandResponse::makeSuccess(id, result); |
| 2661 | } |
| 2662 | |
| 2663 | /** |
| 2664 | * @brief Duplicate an action by id |
nothing calls this directly
no test coverage detected