Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions mslib/msui/mscolab.py
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,7 @@ def __init__(self, parent=None, data_dir=None):
self.ui.actionVersionHistory.triggered.connect(self.operation_options_handler)
self.ui.actionManageUsers.triggered.connect(self.operation_options_handler)
self.ui.actionDeleteOperation.triggered.connect(self.operation_options_handler)
self.ui.actionRenameOperation.triggered.connect(self.rename_operation_handler)
self.ui.actionDescription.triggered.connect(
lambda: QtWidgets.QMessageBox.information(None,
"Operation Description",
Expand Down Expand Up @@ -758,6 +759,9 @@ def add_operation(self):
self.error_dialog.showMessage('Your operation was created successfully')
op_id = self.get_recent_op_id()
self.conn.handle_new_operation(op_id)

# reset operation_description label text
self.ui.activeOperationDesc.setText("Select Operation to View Description.")
else:
self.error_dialog = QtWidgets.QErrorMessage()
self.error_dialog.showMessage('The path already exists')
Expand Down Expand Up @@ -930,6 +934,48 @@ def handle_delete_operation(self):
show_popup(self.ui, "Error", "Your Connection is expired. New Login required!")
self.logout()

def rename_operation_handler(self):
# only after login
if verify_user_token(self.mscolab_server_url, self.token):
entered_operation_name, ok = QtWidgets.QInputDialog.getText(
self.ui,
self.ui.tr("Rename Operation"),
self.ui.tr(
f"You're about to rename the operation - '{self.active_operation_name}' "
f"Enter new operation name: "
),
)
if ok:
data = {
"token": self.token,
"op_id": self.active_op_id,
"attribute": 'path',
"value": entered_operation_name
}
url = url_join(self.mscolab_server_url, 'update_operation')
r = requests.post(url, data=data)
if r.text == "True":
# Update active operation name
self.active_operation_name = entered_operation_name

# Update active operation description
self.active_operation_desc.replace(str(self.active_operation_desc), entered_operation_name)
desc_count = len(str(self.active_operation_desc))
if desc_count < 95:
self.ui.activeOperationDesc.setText(
self.ui.tr(f"{self.active_operation_name}: {self.active_operation_desc}"))
else:
self.ui.activeOperationDesc.setText(
"Description is too long to show here, for long descriptions go "
"to operations menu.")
self.reload_operation_list()
self.reload_windows_slot()
self.error_dialog = QtWidgets.QErrorMessage()
self.error_dialog.showMessage("Operation is renamed successfully.")
else:
show_popup(self.ui, "Error", "Your Connection is expired. New Login required!")
self.logout()

def handle_work_locally_toggle(self):
if verify_user_token(self.mscolab_server_url, self.token):
if self.ui.workLocallyCheckbox.isChecked():
Expand Down
5 changes: 5 additions & 0 deletions mslib/msui/qt5/ui_mainwindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,8 @@ def setupUi(self, MSSMainWindow):
self.actionSearch.setObjectName("actionSearch")
self.actionDescription = QtWidgets.QAction(MSSMainWindow)
self.actionDescription.setObjectName("actionDescription")
self.actionRenameOperation = QtWidgets.QAction(MSSMainWindow)
self.actionRenameOperation.setObjectName("actionRenameOperation")
self.menuNew.addAction(self.actionNewFlightTrack)
self.menuNew.addAction(self.actionAddOperation)
self.menuFile.addAction(self.menuNew.menuAction())
Expand Down Expand Up @@ -204,6 +206,7 @@ def setupUi(self, MSSMainWindow):
self.menuViews.addAction(self.actionLinearView)
self.menuProperties.addAction(self.actionDeleteOperation)
self.menuProperties.addAction(self.actionDescription)
self.menuProperties.addAction(self.actionRenameOperation)
self.menuOperation.addAction(self.actionChat)
self.menuOperation.addAction(self.actionVersionHistory)
self.menuOperation.addAction(self.actionManageUsers)
Expand Down Expand Up @@ -297,4 +300,6 @@ def retranslateUi(self, MSSMainWindow):
self.actionSearch.setToolTip(_translate("MSSMainWindow", "Search for interactive text in the UI"))
self.actionSearch.setShortcut(_translate("MSSMainWindow", "Ctrl+F"))
self.actionDescription.setText(_translate("MSSMainWindow", "Description"))
self.actionRenameOperation.setText(_translate("MSSMainWindow", "Rename Operation"))


6 changes: 6 additions & 0 deletions mslib/msui/ui/ui_mainwindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,7 @@ Double click a operation to activate and view its description.</string>
</property>
<addaction name="actionDeleteOperation"/>
<addaction name="actionDescription"/>
<addaction name="actionRenameOperation"/>
</widget>
<addaction name="actionChat"/>
<addaction name="actionVersionHistory"/>
Expand Down Expand Up @@ -514,6 +515,11 @@ Double click a operation to activate and view its description.</string>
<string>Description</string>
</property>
</action>
<action name="actionRenameOperation">
<property name="text">
<string>Rename Operation</string>
</property>
</action>
</widget>
<tabstops>
<tabstop>connectBtn</tabstop>
Expand Down