Skip to content

Commit

Permalink
view process after creation
Browse files Browse the repository at this point in the history
  • Loading branch information
aman-alfresco committed Apr 1, 2024
1 parent 5bf4885 commit 5cc9aef
Show file tree
Hide file tree
Showing 35 changed files with 362 additions and 185 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ class ProcessDefinitionsSheet : BottomSheetDialogFragment(), MavericksView {
val intent = Intent(
requireActivity(),
Class.forName("com.alfresco.content.app.activity.ProcessActivity"),
// Class.forName("com.alfresco.content.process.ui.ProcessFormActivity"),
)
intent.putExtra(Mavericks.KEY_ARG, processEntry)
startActivity(intent)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.alfresco.content.browse.processes.details

import com.alfresco.content.browse.tasks.list.UpdateTasksData
import com.alfresco.content.process.ui.models.UpdateProcessData
import com.alfresco.content.process.ui.models.UpdateTasksData
import com.alfresco.events.EventBus
import kotlinx.coroutines.launch

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,13 @@ class TaskStatusFragment : Fragment(), MavericksView {
}

override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
inflater.inflate(R.menu.menu_task_status, menu)
inflater.inflate(R.menu.menu_process, menu)
}

override fun onOptionsItemSelected(item: MenuItem): Boolean {
return when (item.itemId) {
R.id.action_save -> {
viewModel.saveForm(binding.commentInput.text.toString().trim())
// viewModel.saveForm(binding.commentInput.text.toString().trim())
true
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,9 @@ import com.alfresco.content.common.updatePriorityView
import com.alfresco.content.component.ComponentData
import com.alfresco.content.component.ComponentType
import com.alfresco.content.component.DatePickerBuilder
import com.alfresco.content.data.AnalyticsManager
import com.alfresco.content.data.TaskEntry
import com.alfresco.content.formatDate
import com.alfresco.content.getFormattedDate
import com.alfresco.content.getLocalizedName
import com.alfresco.content.parseDate
import com.alfresco.content.setSafeOnClickListener
import com.google.android.material.button.MaterialButton
Expand Down Expand Up @@ -56,9 +54,13 @@ internal fun TaskDetailFragment.updateTaskDetailUI(isEdit: Boolean) = withState(
}

internal fun TaskDetailFragment.enableTaskFormUI() = withState(viewModel) { state ->
binding.tvTitle.visibility = View.GONE
binding.tvDescription.visibility = View.GONE
binding.clComment.visibility = View.GONE
binding.clIdentifier.visibility = View.GONE
binding.iconStatusNav.visibility = View.VISIBLE
binding.clDueDate.visibility = View.GONE
binding.clPriority.visibility = View.GONE
binding.clIdentifier.visibility = View.VISIBLE
binding.iconStatusNav.visibility = View.GONE
binding.iconStatus.setImageResource(R.drawable.ic_task_status_star)

binding.clStatus.setSafeOnClickListener {
Expand Down Expand Up @@ -113,15 +115,15 @@ internal fun TaskDetailFragment.setTaskDetailAfterResponse(dataObj: TaskEntry) =
makeClaimButton()
} else if (viewModel.isAssigneeAndLoggedInSame(dataObj.assignee)) {
menuDetail.findItem(R.id.action_release).isVisible = true
makeOutcomes()
// makeOutcomes()
}
}

else -> {
if (viewModel.isStartedByAndLoggedInSame(dataObj.processInstanceStartUserId) ||
viewModel.isAssigneeAndLoggedInSame(dataObj.assignee)
) {
makeOutcomes()
// makeOutcomes()
}
}
}
Expand Down Expand Up @@ -260,34 +262,6 @@ internal fun TaskDetailFragment.showTitleDescriptionComponent() = withState(view
}
}

internal fun TaskDetailFragment.makeOutcomes() = withState(viewModel) { state ->
if (binding.parentOutcomes.childCount == 0) {
state.parent?.outcomes?.forEach { dataObj ->
val button = if (dataObj.outcome.lowercase() == "reject") {
this.layoutInflater.inflate(R.layout.view_layout_negative_outcome, binding.parentOutcomes, false) as MaterialButton
} else {
this.layoutInflater.inflate(R.layout.view_layout_positive_outcome, binding.parentOutcomes, false) as MaterialButton
}
button.text = requireContext().getLocalizedName(dataObj.name)
button.setOnClickListener {
withState(viewModel) { newState ->
if (viewModel.hasTaskStatusEnabled(newState) && !viewModel.hasTaskStatusValue(newState)
) {
showSnackar(
binding.root,
getString(R.string.error_select_status),
)
} else {
AnalyticsManager().taskFiltersEvent(dataObj.outcome)
viewModel.actionOutcome(dataObj.outcome)
}
}
}
binding.parentOutcomes.addView(button)
}
}
}

internal fun TaskDetailFragment.makeClaimButton() = withState(viewModel) { state ->
if (binding.parentOutcomes.childCount == 0) {
val button = this.layoutInflater.inflate(R.layout.view_layout_positive_outcome, binding.parentOutcomes, false) as MaterialButton
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ class TaskDetailViewModel(
is Fail -> copy(request = Fail(it.error))
is Success -> {
val updateState = update(it())
if (isWorkflowTask) getTaskForms(updateState)
updateState.copy(request = Success(it()))
}

Expand Down Expand Up @@ -377,29 +376,6 @@ class TaskDetailViewModel(
}
}

private fun getTaskForms(oldState: TaskDetailViewState) = withState { state ->
requireNotNull(oldState.parent)
viewModelScope.launch {
repository::getTaskForm.asFlow(oldState.parent.id).execute {
when (it) {
is Loading -> copy(requestTaskForm = Loading())
is Fail -> {
it.error.printStackTrace()
copy(requestTaskForm = Fail(it.error))
}

is Success -> {
update(oldState.parent, it()).copy(requestTaskForm = Success(it()))
}

else -> {
this
}
}
}
}
}

/**
* update the status of task related to workflow
*/
Expand Down Expand Up @@ -446,31 +422,6 @@ class TaskDetailViewModel(
}
}

/**
* execute the save-form api
*/
fun saveForm(comment: String) = withState { state ->
requireNotNull(state.parent)
viewModelScope.launch {
repository::saveForm.asFlow(state.parent, comment).execute {
when (it) {
is Loading -> copy(requestSaveForm = Loading())
is Fail -> {
copy(requestSaveForm = Fail(it.error))
}

is Success -> {
copy(requestSaveForm = Success(it()))
}

else -> {
this
}
}
}
}
}

/**
* execute API to claim the task
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package com.alfresco.content.browse.tasks.detail

import com.alfresco.content.actions.Action
import com.alfresco.content.browse.tasks.list.UpdateTasksData
import com.alfresco.content.data.Entry
import com.alfresco.content.data.OfflineRepository
import com.alfresco.content.data.UserGroupDetails
import com.alfresco.content.process.ui.models.UpdateProcessData
import com.alfresco.content.process.ui.models.UpdateTasksData
import com.alfresco.events.EventBus
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import com.alfresco.content.data.AnalyticsManager
import com.alfresco.content.data.EventName
import com.alfresco.content.data.PageView
import com.alfresco.content.data.ParentEntry
import com.alfresco.content.data.ProcessEntry
import com.alfresco.content.data.TaskEntry
import com.alfresco.content.data.TaskFilterData
import com.alfresco.content.hideSoftInput
Expand Down Expand Up @@ -189,11 +190,21 @@ class TasksFragment : TaskListFragment<TasksViewModel, TasksViewState>() {
) = continuation.resume(ComponentMetaData(name = name, query = query, queryMap = queryMap))

override fun onItemClicked(entry: TaskEntry) {
val intent = Intent(
requireActivity(),
Class.forName("com.alfresco.content.app.activity.TaskViewerActivity"),
)
intent.putExtra(Mavericks.KEY_ARG, entry)
val intent = if (entry.processInstanceId != null) {
Intent(
requireActivity(),
Class.forName("com.alfresco.content.app.activity.ProcessActivity"),
).apply {
putExtra(Mavericks.KEY_ARG, ProcessEntry.with(entry))
}
} else {
Intent(
requireActivity(),
Class.forName("com.alfresco.content.app.activity.TaskViewerActivity"),
).apply {
putExtra(Mavericks.KEY_ARG, entry)
}
}
startActivity(intent)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import com.alfresco.content.data.payloads.TaskProcessFiltersPayload
import com.alfresco.content.getLocalizedName
import com.alfresco.content.listview.tasks.TaskListViewModel
import com.alfresco.content.listview.tasks.TaskListViewState
import com.alfresco.content.process.ui.models.UpdateTasksData
import com.alfresco.coroutines.asFlow
import com.alfresco.events.on
import kotlinx.coroutines.GlobalScope
Expand Down Expand Up @@ -233,8 +234,3 @@ class TasksViewModel(
) = TasksViewModel(state, viewModelContext.activity, TaskRepository())
}
}

/**
* Mark as UpdateTasksData data class
*/
data class UpdateTasksData(val isRefresh: Boolean)
1 change: 0 additions & 1 deletion browse/src/main/res/values-de/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@
<string name="text_attached_files">Angehängte Dateien</string>
<string name="no_attached_files">Keine angehängten Dateien</string>
<string name="empty_no_due_date">Kein Fälligkeitsdatum</string>
<string name="text_complete">Abgeschlossen</string>
<string name="dialog_title_complete_task">Aufgabe abschließen</string>
<string name="dialog_message_complete_task">Sind Sie sicher, dass Sie diese Aufgabe abschließen wollen? Sie werden keine Änderungen mehr vornehmen können.</string>
<string name="icon_send_description">Schaltfläche „Senden“</string>
Expand Down
1 change: 0 additions & 1 deletion browse/src/main/res/values-es/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@
<string name="text_attached_files">Ficheros adjuntos</string>
<string name="no_attached_files">No hay ficheros adjuntos</string>
<string name="empty_no_due_date">Sin fecha de vencimiento</string>
<string name="text_complete">Por completar</string>
<string name="dialog_title_complete_task">Completar tarea</string>
<string name="dialog_message_complete_task">¿Está seguro de que desea completar esta tarea? Ya no podrá realizar ningún cambio.</string>
<string name="icon_send_description">Botón Enviar</string>
Expand Down
1 change: 0 additions & 1 deletion browse/src/main/res/values-fr/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@
<string name="text_attached_files">Fichiers joints</string>
<string name="no_attached_files">Aucun fichier joint</string>
<string name="empty_no_due_date">Aucune date d\'échéance</string>
<string name="text_complete">Terminé</string>
<string name="dialog_title_complete_task">Terminer la tâche</string>
<string name="dialog_message_complete_task">Voulez-vous vraiment terminer cette tâche ? Vous ne pourrez plus faire de modifications.</string>
<string name="icon_send_description">Bouton Envoyer</string>
Expand Down
1 change: 0 additions & 1 deletion browse/src/main/res/values-it/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@
<string name="text_attached_files">File allegati</string>
<string name="no_attached_files">Nessun file allegato</string>
<string name="empty_no_due_date">Nessuna scadenza</string>
<string name="text_complete">Completato</string>
<string name="dialog_title_complete_task">Completa compito</string>
<string name="dialog_message_complete_task">Vuoi completare il compito? Non potrai più apportare modifiche.</string>
<string name="dialog_negative_button_task">Annulla</string>
Expand Down
1 change: 0 additions & 1 deletion browse/src/main/res/values-nl/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@
<string name="text_attached_files">Bijgevoegde bestanden</string>
<string name="no_attached_files">Geen bijgevoegde bestanden</string>
<string name="empty_no_due_date">Geen vervaldatum</string>
<string name="text_complete">Voltooien</string>
<string name="dialog_title_complete_task">Taak voltooien</string>
<string name="dialog_message_complete_task">Weet u zeker dat u de taak wilt voltooien? U kunt geen wijzigingen meer aanbrengen.</string>
<string name="icon_send_description">Knop Verzenden</string>
Expand Down
1 change: 0 additions & 1 deletion browse/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@
<string name="text_attached_files">Attached files</string>
<string name="no_attached_files">No Attached Files</string>
<string name="empty_no_due_date">No due date</string>
<string name="text_complete">Complete</string>
<string name="dialog_title_complete_task">Complete Task</string>
<string name="dialog_message_complete_task">Are you sure you want to complete this task? You will no longer be able to make any changes.</string>
<string name="icon_send_description">Send Button</string>
Expand Down
1 change: 1 addition & 0 deletions common/src/main/res/values-de/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,5 @@
<string name="dialog_title_delete_content">Eine Datei löschen?</string>
<string name="dialog_negative_button_task">Abbrechen</string>
<string name="dialog_positive_button_task">Bestätigen</string>
<string name="text_complete">Abgeschlossen</string>
</resources>
1 change: 1 addition & 0 deletions common/src/main/res/values-es/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,5 @@
<string name="dialog_title_delete_content">¿Eliminar un fichero?</string>
<string name="dialog_negative_button_task">Cancelar</string>
<string name="dialog_positive_button_task">Confirmar</string>
<string name="text_complete">Por completar</string>
</resources>
1 change: 1 addition & 0 deletions common/src/main/res/values-fr/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,6 @@
<string name="dialog_title_delete_content">Supprimer un fichier ?</string>
<string name="dialog_negative_button_task">Annuler</string>
<string name="dialog_positive_button_task">Confirmer</string>
<string name="text_complete">Terminé</string>

</resources>
1 change: 1 addition & 0 deletions common/src/main/res/values-it/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,5 @@
<string name="dialog_title_delete_content">Vuoi eliminare un file?</string>
<string name="dialog_title_discard_task">Ignora</string>
<string name="dialog_message_discard_task">Vuoi ignorare le modifiche?</string>
<string name="text_complete">Completato</string>
</resources>
1 change: 1 addition & 0 deletions common/src/main/res/values-nl/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,5 @@
<string name="dialog_title_delete_content">Bestand verwijderen?</string>
<string name="dialog_negative_button_task">Annuleren</string>
<string name="dialog_positive_button_task">Bevestigen</string>
<string name="text_complete">Voltooien</string>
</resources>
1 change: 1 addition & 0 deletions common/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,5 @@
<string name="dialog_title_delete_content">Delete a file?</string>
<string name="dialog_negative_button_task">Cancel</string>
<string name="dialog_positive_button_task">Confirm</string>
<string name="text_complete">Complete</string>
</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,11 @@ data class OptionsModel(
}
}
}

enum class DefaultOutcomesID {
DEFAULT_START_WORKFLOW,
DEFAULT_SAVE,
DEFAULT_COMPLETE,
;
fun value() = name.lowercase()
}
13 changes: 13 additions & 0 deletions data/src/main/kotlin/com/alfresco/content/data/ProcessEntry.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ data class ProcessEntry(
val description: String = "",
val businessKey: String? = null,
val processDefinitionId: String? = null,
val processInstanceId: String? = null,
val tenantId: String? = null,
val started: ZonedDateTime? = null,
val ended: ZonedDateTime? = null,
Expand All @@ -34,6 +35,7 @@ data class ProcessEntry(
val formattedDueDate: String? = null,
val defaultEntries: List<Entry> = emptyList(),
val reviewerType: ReviewerType = ReviewerType.OTHER,
val taskEntry: TaskEntry = TaskEntry(),
) : ParentEntry(), Parcelable {

companion object {
Expand Down Expand Up @@ -76,6 +78,17 @@ data class ProcessEntry(
)
}

/**
* return the ProcessEntry using TaskEntry
*/
fun with(data: TaskEntry): ProcessEntry {
return ProcessEntry(
description = data.description ?: "",
processInstanceId = data.processInstanceId,
taskEntry = data,
)
}

/**
* return the ProcessEntry using RuntimeProcessDefinitionDataEntry
*/
Expand Down
Loading

0 comments on commit 5cc9aef

Please sign in to comment.