public ContentReference Update(NodeContent nodeContent, Node node, SaveAction saveAction) { if (string.IsNullOrEmpty(node.urlSegment) == false) { nodeContent.RouteSegment = node.urlSegment; } else { nodeContent.RouteSegment = node.code.ToLowerInvariant(); } //Set the Name nodeContent.Name = node.name; nodeContent.DisplayName = node.name; // Override with language var displayName = GetPropertyValue(node, RootCatalog.DefaultLanguage, "DisplayName"); if (string.IsNullOrEmpty(displayName) == false) { nodeContent.DisplayName = displayName; } //Publish the new content and return its ContentReference. return _contentRepository.Save(nodeContent, saveAction, AccessLevel.NoAccess); }
/// <summary> /// Returns the properties of a model class that may be affected by an INSERT or UPDATE statement. /// For example calculated and identity columns are omitted. /// </summary> /// <typeparam name="T">Model class type</typeparam> /// <param name="action">Indicates whether an insert or update is in effect</param> protected IEnumerable <ColumnInfo> EditableColumns <T>(SaveAction action) { string identity = typeof(T).GetIdentityName().ToLower(); var props = typeof(T).GetProperties().Where(pi => !pi.GetColumnName().ToLower().Equals(identity)).ToArray(); return(props.Where(pi => IsEditable(pi, action)).Select(pi => new ColumnInfo(pi)).ToArray()); }
public SingleEmpleado(SaveAction action, Models.Empleados empleado) { InitializeComponent(); currentAction = action; TypeInit(); currentClient = empleado; textBox1.Text = currentClient.Nombre; textBox3.Text = currentClient.Cedula; comboBox1.Text = (currentClient.TandaLabor == 1) ? "Matutina" : (currentClient.TandaLabor == 2) ? "Vespertina" : "Nocturna"; textBox4.Text = currentClient.PorcientoComision.ToString(); dateTimePicker1.Value = currentClient.FechaIngreso; checkBox1.Checked = currentClient.Estado; textBox1.Size = new Size(508, 25); if (action == SaveAction.Ver) { textBox1.Enabled = false; textBox3.Enabled = false; comboBox1.Enabled = false; textBox4.Enabled = false; dateTimePicker1.Enabled = false; checkBox1.Enabled = false; button1.Enabled = false; } }
public void Save() { foreach (Action SaveAction in SaveActions) { SaveAction?.Invoke(); } }
public SingleMarca(SaveAction action) { InitializeComponent(); currentAction = action; TypeInit(); currentType = new Models.Marcas(); }
public override async Task AfterSaveAsync(IDbConnection connection, SaveAction action, IUser user) { if (action == SaveAction.Insert) { var workItem = await connection.FindAsync <WorkItem>(WorkItemId); workItem.ActivityId = ToActivityId; workItem.LastHandOffId = Id; await connection.SaveAsync(workItem, user); var toActivity = await connection.FindAsync <Activity>(ToActivityId); var fromActivity = await connection.FindAsync <Activity>(FromActivityId); string displayUser = await OrganizationUser.GetUserDisplayNameAsync(connection, workItem.OrganizationId, FromUserId, user); string text = $"{displayUser} handed off work item {workItem.Number} from {fromActivity.Name} to {toActivity.Name}"; int eventLogId = await EventLog.WriteAsync(connection, new EventLog(WorkItemId, user) { EventId = (IsForward) ? SystemEvent.HandOffForward : SystemEvent.HandOffBackward, IconClass = GetIconClass(IsForward), IconColor = GetColor(IsForward), HtmlBody = text, TextBody = text, SourceId = Id, SourceTable = "HandOff" }); await Notification.CreateFromActivitySubscriptions(connection, eventLogId); } }
private bool IsEditable(PropertyInfo propertyInfo, SaveAction action) { if (propertyInfo.DeclaringType.IsInterface) { return(true); } if (!propertyInfo.CanWrite) { return(false); } if (!IsSupportedType(propertyInfo.PropertyType)) { return(false); } if (!IsMapped(propertyInfo)) { return(false); } if (IsCalculated(propertyInfo)) { return(false); } var colInfo = new ColumnInfo(propertyInfo); return((colInfo.SaveActions & action) == action); }
public override void BeforeSave(IDbConnection connection, SqlDb <int> db, SaveAction action) { if (Parameters != null) { ParameterValues = GetParameterValueString(); } }
public override async Task AfterSaveAsync(IDbConnection connection, SaveAction action, IUser user) { await base.AfterSaveAsync(connection, action, user); if (action == SaveAction.Insert) { if (ObjectType == ObjectType.WorkItem) { var workItem = await connection.FindAsync <WorkItem>(ObjectId); if (IsImpediment.HasValue) { workItem.HasImpediment = IsImpediment.Value; await connection.UpdateAsync(workItem, user, r => r.HasImpediment); } await EventLog.WriteAsync(connection, new EventLog(ObjectId, user) { TeamId = workItem.TeamId, EventId = (IsImpediment ?? false) ? SystemEvent.ImpedimentAdded : SystemEvent.CommentAdded, IconClass = IconClass, IconColor = (IsImpediment ?? false) ? "darkred" : "auto", HtmlBody = HtmlBody, TextBody = TextBody }); } await PendingWorkLog.FromCommentAsync(connection, this, user as UserProfile); await ParseMentionsAsync(connection, this, user as UserProfile); } }
/// <summary> /// Raises the Saved event. /// </summary> protected static void OnSaved(BusinessBase <TYPE, KEY> businessObject, SaveAction action) { if (Saved != null) { Saved(businessObject, new SavedEventArgs(action)); } }
public override async Task AfterSaveAsync(IDbConnection connection, SaveAction action, IUser user) { if (action == SaveAction.Update) { await SyncWorkItemsToProjectAsync(connection); } }
/// <summary> /// Raises the Saving event /// </summary> /// <param name="businessObject"> /// The business Object. /// </param> /// <param name="action"> /// The action. /// </param> protected static void OnSaving(BusinessBase <T, TKey> businessObject, SaveAction action) { if (Saving != null) { Saving(businessObject, new SavedEventArgs(action)); } }
/// <summary> /// Raises the Saved event. /// </summary> /// <param name="businessObject"> /// The business Object. /// </param> /// <param name="action"> /// The action. /// </param> public void OnSaved(Object savedObject, SaveAction action) { if (Saved != null) { Saved(savedObject, new SavedEventArgs(action)); } }
public SingleTipoVehiculo(SaveAction action) { InitializeComponent(); currentAction = action; TypeInit(); currentType = new VehiculosTipos(); }
/// <summary> /// Raises the Saving event /// </summary> protected void OnSaving(BusinessBase <TYPE, KEY> businessObject, SaveAction action) { if (_saving != null) { _saving(businessObject, new SavedEventArgs(action)); } }
public SingleCliente(SaveAction action, Models.Clientes cliente) { InitializeComponent(); currentAction = action; TypeInit(); currentClient = cliente; textBox1.Text = currentClient.Nombre; textBox3.Text = currentClient.Cedula; comboBox1.Text = (currentClient.TipoPersona == 1) ? "Persona Física" : "Persona Jurídica"; textBox4.Text = currentClient.NoTarjeta; textBox5.Text = currentClient.LimiteCredito.ToString(); checkBox1.Checked = currentClient.Estado; textBox1.Size = new Size(508, 25); if (currentAction == SaveAction.Ver) { textBox1.Enabled = false; textBox3.Enabled = false; comboBox1.Enabled = false; textBox4.Enabled = false; textBox5.Enabled = false; checkBox1.Enabled = false; button1.Enabled = false; button2.Text = "Salir"; } }
public ContentReference Update(NodeContent nodeContent, Node node, SaveAction saveAction) { if (string.IsNullOrEmpty(node.urlSegment) == false) { nodeContent.RouteSegment = node.urlSegment; } else { nodeContent.RouteSegment = node.code.ToLowerInvariant(); } //Set the Name nodeContent.Name = node.name; nodeContent.DisplayName = node.name; // Override with language var displayName = GetPropertyValue(node, RootCatalog.DefaultLanguage, "DisplayName"); if (string.IsNullOrEmpty(displayName) == false) { nodeContent.DisplayName = displayName; } //Publish the new content and return its ContentReference. return(_contentRepository.Save(nodeContent, saveAction, AccessLevel.NoAccess)); }
/// <summary> /// Save /// </summary> public void Save() { using (var dlg = new System.Windows.Forms.SaveFileDialog { #pragma warning disable CA1303 // Do not pass literals as localized parameters Filter = FileFilters.TestFileFilter, #pragma warning restore CA1303 // Do not pass literals as localized parameters InitialDirectory = Configuration.TestReportPath, AutoUpgradeEnabled = !SystemParameters.HighContrast, }) { dlg.FileName = dlg.InitialDirectory.GetSuggestedFileName(FileType.TestResults); if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK) { try { SaveAction.SaveSnapshotZip(dlg.FileName, this.ElementContext.Id, null, A11yFileMode.Test); } #pragma warning disable CA1031 // Do not catch general exception types catch (Exception ex) { MessageDialog.Show(string.Format(CultureInfo.InvariantCulture, Properties.Resources.TestModeControl_SaveExceptionFormat, dlg.FileName, ex.Message)); } #pragma warning restore CA1031 // Do not catch general exception types } } }
public SingleTipoCombustible(SaveAction action) { InitializeComponent(); currentAction = action; TypeInit(); currentType = new CombustiblesTipos(); }
/// <summary> /// Init menu /// </summary> private void InitHeaderActions() { // Save action SaveAction save = new SaveAction(); headerActions.ActionsList.Add(save); // Preview HeaderAction preview = new HeaderAction { Text = GetString("general.preview"), OnClientClick = "performToolbarAction('split');return false;", Visible = (previewState == 0), Tooltip = GetString("preview.tooltip") }; headerActions.ActionsList.Add(preview); headerActions.ActionPerformed += (sender, e) => { if (e.CommandName == ComponentEvents.SAVE) { Save(); } }; }
/// <summary> /// 触发 <see cref="Saved"/> 事件. /// </summary> protected virtual void OnSaved(DomainObjectBase <TID> businessObject, SaveAction action) { if (Saved != null) { Saved(businessObject, new SavedEventArgs(action)); } }
public MessagingContext() { SaveCommand = new DelegateCommand(() => { SaveAction?.Invoke(); }); }
private void SaveInner <TRecord>(IDbConnection connection, TRecord record, SaveAction action, Action <TRecord, IDbTransaction> saveAction, IDbTransaction transaction = null) where TRecord : Record <TKey>, new() { record.BeforeSave(connection, this, action); string message; if (record.IsValid(connection, action, out message)) { if (record.AllowSave(connection, this, out message)) { string ignoreProps; if (action == SaveAction.Update && TrackChanges <TRecord>(out ignoreProps)) { CaptureChanges(connection, record, ignoreProps); } saveAction.Invoke(record, transaction); record.AfterSave(connection, this, action); } else { throw new PermissionDeniedException(message); } } else { throw new ValidationException(message); } }
public override async Task BeforeSaveAsync(IDbConnection connection, SaveAction action, IUser user) { await base.BeforeSaveAsync(connection, action, user); if (OptionId == 0 && !string.IsNullOrEmpty(OptionName)) { var opt = await connection.FindWhereAsync <Option>(new { name = OptionName }); OptionId = opt.Id; OptionType = opt.OptionType; } if (_value != null) { switch (OptionType.StorageColumn) { case nameof(StringValue): StringValue = _value as string; break; case nameof(IntValue): IntValue = int.Parse(_value as string); break; case nameof(BoolValue): BoolValue = bool.Parse(_value as string); break; } } }
/// <summary> /// Handle PreRenderComplete event of the page. /// </summary> /// <param name="sender">Sender object</param> /// <param name="e">Event argument</param> protected void Page_PreRenderComplete(object sender, EventArgs e) { if ((siteInfo != null) && !RequestHelper.IsPostBack()) { // Check version limitations if (!CultureSiteInfoProvider.LicenseVersionCheck(siteInfo.DomainName, FeatureEnum.Multilingual, ObjectActionEnum.Edit)) { Control.ShowError(ResHelper.GetString("licenselimitation.siteculturesexceeded")); // Disable culture selector FormEngineUserControl cultureSelector = Control.FieldControls["SiteDefaultVisitorCulture"]; if (cultureSelector != null) { cultureSelector.Enabled = false; } // Disable Save button HeaderActions actions = Control.ObjectManager.HeaderActions; SaveAction sa = actions.ActionsList.Where <HeaderAction>(a => (a is SaveAction)).First() as SaveAction; if (sa != null) { sa.Enabled = false; sa.BaseButton.Visible = true; actions.ReloadData(); Control.SubmitButton.Visible = false; } } } }
public void Save(VehiculosTipos tipo, SaveAction accion) { using (var ctx = new GrullonRCEntities()) { if (accion == SaveAction.Agregar) { ctx.VehiculosTipos.Add(tipo); } if (accion == SaveAction.Editar) { var toUpdate = ctx.VehiculosTipos.FirstOrDefault(x => x.Id == tipo.Id); toUpdate.Descripcion = tipo.Descripcion; toUpdate.Estado = tipo.Estado; } if (accion == SaveAction.Eliminar) { var toDelete = ctx.VehiculosTipos.FirstOrDefault(x => x.Id == tipo.Id); toDelete.Deleted = true; } ctx.SaveChanges(); } }
public SaveFilterForm(SaveAction action, string title) { InitializeComponent(); text = title; fmAction = action; try { lSavedCriteria = XmlSerialization.ReadFromXmlFile <List <SavedCriteria> >("SavedFilter.txt"); foreach (SavedCriteria sc in lSavedCriteria) { cboSavedName.Items.Add(sc.Name); } cboSavedName.SelectedIndex = 0; } catch (System.IO.FileNotFoundException e) { MessageBox.Show("Did not find file 'SavedFilter.txt'. Saving a Filter will automatically create a new file in the same directory as the editor."); } catch { MessageBox.Show("Could not read 'SavedFilter.txt'"); this.Close(); } }
/// <summary> /// Initializes header action control. /// </summary> private void InitHeaderActions() { var btnSave = new SaveAction(Page) { Permission = "Manage", ResourceName = "CMS.ABTest" }; HeaderActions.AddAction(btnSave); switch (TestStatus) { case ABTestStatusEnum.NotStarted: if (ABTest.ABTestID != 0) { AddStartTestButton(); } break; case ABTestStatusEnum.Scheduled: AddStartTestButton(); break; case ABTestStatusEnum.Running: AddFinishTestButton(); break; } }
private void SaveEvent(Event @event, SaveAction action) { using (var connection = connectionFactory.Connect()) { connection.Open(); using (var transaction = connection.BeginTransaction()) { try { if (action == SaveAction.CREATE) { CreateEvent(@event, connection, transaction); } else if (action == SaveAction.UPDATE) { UpdateEvent(@event, connection, transaction); } UpdateSquadEvents(@event, connection, transaction); UpdateEventTrainingMaterials(@event, connection, transaction); transaction.Commit(); } catch (Exception ex) { transaction.Rollback(); throw ex; } } } }
/// <summary> /// Init menu /// </summary> private void InitHeaderActions() { // Save action SaveAction save = new SaveAction(Page); headerActions.ActionsList.Add(save); // Preview HeaderAction preview = new HeaderAction() { ControlType = HeaderActionTypeEnum.LinkButton, Text = GetString("general.preview"), OnClientClick = "performToolbarAction('split');return false;", ImageUrl = GetImageUrl("CMSModules/CMS_Content/EditMenu/Preview.png"), SmallImageUrl = GetImageUrl("CMSModules/CMS_Content/EditMenu/16/Preview.png"), Visible = (previewState == 0), Tooltip = GetString("preview.tooltip") }; headerActions.ActionsList.Add(preview); headerActions.ActionPerformed += (sender, e) => { if (e.CommandName == ComponentEvents.SAVE) { Save(); } }; }
public SingleVehiculo(SaveAction action) { InitializeComponent(); currentAction = action; TypeInit(); FillCombos(); }
public override async Task AfterSaveAsync(IDbConnection connection, SaveAction action, IUser user) { if (action == SaveAction.Insert) { var workItem = await connection.FindAsync <WorkItem>(WorkItemId); var label = await connection.FindAsync <Label>(LabelId); string displayUser = await OrganizationUser.GetUserDisplayNameAsync(connection, workItem.OrganizationId, user.UserName); string text = $"{displayUser} added label {label.Name} to work item {workItem.Number}"; string html = $"{displayUser} added label <strong>{label.Name}</strong> to work item {workItem.Number}"; int eventLogId = await EventLog.WriteAsync(connection, new EventLog() { OrganizationId = workItem.OrganizationId, TeamId = workItem.TeamId, ApplicationId = workItem.ApplicationId, WorkItemId = workItem.Id, EventId = SystemEvent.LabelAdded, IconClass = IconClass, IconColor = IconColor, HtmlBody = html, TextBody = text, SourceId = Id, SourceTable = nameof(WorkItemLabel) }, user); await Notification.CreateFromLabelSubscriptions(connection, eventLogId); } }
public ContentReference Save(ContentPage contentPage, SaveAction saveAction = SaveAction.Publish, AccessLevel accessLevel = AccessLevel.NoAccess) { if (contentPage == null) return null; return _epiServerDependencies.ContentRepository .Save(contentPage, saveAction, accessLevel); }
private void DefaultConfig() { GenerateDBMSOutput = false; OrmCodeGeneration = Orm.NHibernate; SaveAction = SaveAction.Overwrite; FileSaveMode = SaveMode.DistinctFile; SaveFolder = Environment.GetFolderPath(Environment.SpecialFolder.CommonDesktopDirectory) + "\\Code"; MapGenSettings = new MapGenSettings { GenereteDomainEqualityComparer = false, GeneretePartialDomain = false, }; }
protected void Page_Load(object sender, EventArgs e) { // Get TemplateID templateID = QueryHelper.GetInteger("templateid", 0); if (templateID == 0) { return; } templateTextElem.TemplateID = templateID; // Show info message if changes were saved if (QueryHelper.GetBoolean("saved", false)) { // Show message ShowChangesSaved(); } if (templateTextElem.GatewayCount <= 10) { SaveAction saveAction = new SaveAction(Page); if (templateTextElem.GatewayCount == 0) { saveAction.Enabled = false; } CurrentMaster.HeaderActions.ActionsList.Add(saveAction); CurrentMaster.HeaderActions.ActionPerformed += HeaderActions_ActionPerformed; // Macros help plcMacros.Visible = true; lnkMoreMacros.Text = GetString("notification.template.text.helplnk"); lblHelpHeader.Text = GetString("notification.template.text.helpheader"); DisplayHelperTable(); } }
/// <summary> /// Ensures header actions. /// </summary> private void EnsureHeaderActions(bool reload) { if (HeaderActions == null) { return; } if (HeaderActions.ActionsList.Exists(a => (a is SaveAction && a.Visible))) { // Get save from default page actions var saveAction = (SaveAction)HeaderActions.ActionsList.Single(a => a is SaveAction); if ((btnSave == null) || (btnSave != saveAction)) { btnSave = saveAction; } } if (btnSave == null) { // Create new action btnSave = new SaveAction(Page); btnSave.Enabled = Enabled; HeaderActions.InsertAction(-2, btnSave); if (reload) { HeaderActions.ReloadData(); } } if (!UseCustomHeaderActions) { if (HeaderActions.MessagesPlaceHolder != null) { HeaderActions.MessagesPlaceHolder.OffsetX = 250; } var manager = CMSObjectManager.GetCurrent(Page); if (manager != null) { manager.ShowPanel = true; manager.OnSaveData += ObjectManager_OnSaveData; manager.OnAfterAction += ObjectManager_OnAfterAction; } } HeaderActions.ActionPerformed += HeaderActions_ActionPerformed; HeaderActions.PerformFullPostBack = false; if (reload) { if (btnSave != null && disableSaveAction) { // Disable save action btnSave.Enabled = false; } // Hide action buttons if edited object is checked in or checked out by another user if (((btnSave == null || !btnSave.Enabled) && (IsObjectChecked())) || !Enabled) { // Disable control elements pnlContent.Enabled = btnAdd.Enabled = documentSource.Enabled = btnUpAttribute.Enabled = btnDownAttribute.Enabled = btnNewCategory.Enabled = btnNewAttribute.Enabled = btnDeleteItem.Enabled = false; // Disable mode switch for disabled dialog controlSettings.AllowModeSwitch = false; controlSettings.SimpleMode = false; } } }
/// <summary> /// Creates header actions - save and reset buttons. /// </summary> private void CreateHeaderActions() { if (!UseCustomHeaderActions && HeaderActions == null) { return; } // Create Reset button btnReset = new HeaderAction { CommandName = "reset", Visible = false }; if (UseCustomHeaderActions) { // Add save action btnSave = new SaveAction(Page); btnSave.Enabled = Enabled; HeaderActions.AddAction(btnSave); HeaderActions.AddAction(btnReset); pnlHeaderActions.Visible = pnlHeaderPlaceHolder.Visible = true; pnlContentPadding.CssClass += " Menu"; } else { ObjectEditMenu menu = (ObjectEditMenu)ControlsHelper.GetChildControl(Page, typeof(ObjectEditMenu)); if (menu != null) { menu.AddExtraAction(btnReset); menu.AllowSave = Enabled; } else if (HeaderActions != null) { HeaderActions.AddAction(btnReset); } } controlSettings.BasicForm.EnsureMessagesPlaceholder(MessagesPlaceHolder); }
protected void Page_Load(object sender, EventArgs e) { // Check 'ReadForm' and 'EditData' permission if (!CMSContext.CurrentUser.IsAuthorizedPerResource("cms.form", "ReadForm")) { RedirectToCMSDeskAccessDenied("cms.form", "ReadForm"); } // Get form id from URL formId = QueryHelper.GetInteger("formid", 0); // Add save action save = new SaveAction(Page); menu.AddAction(save); // Register for action ComponentEvents.RequestEvents.RegisterForEvent(ComponentEvents.SAVE, lnkSave_Click); // Control initialization ltlConfirmDelete.Text = "<input type=\"hidden\" id=\"confirmdelete\" value=\"" + GetString("Bizform_Edit_Notificationemail.ConfirmDelete") + "\">"; chkSendToEmail.Text = GetString("BizFormGeneral.chkSendToEmail"); chkAttachDocs.Text = GetString("BizForm_Edit_NotificationEmail.AttachUploadedDocs"); chkCustomLayout.Text = GetString("BizForm_Edit_NotificationEmail.CustomLayout"); // Initialize HTML editor InitHTMLEditor(); BizFormInfo bfi = BizFormInfoProvider.GetBizFormInfo(formId); EditedObject = bfi; if (!RequestHelper.IsPostBack()) { if (bfi != null) { // Get form class object formClassObj = DataClassInfoProvider.GetDataClass(bfi.FormClassID); // Fill list of available fields FillFieldsList(); // Load email from/to address and email subject txtFromEmail.Text = ValidationHelper.GetString(bfi.FormSendFromEmail, ""); txtToEmail.Text = ValidationHelper.GetString(bfi.FormSendToEmail, ""); txtSubject.Text = ValidationHelper.GetString(bfi.FormEmailSubject, ""); chkAttachDocs.Checked = bfi.FormEmailAttachUploadedDocs; chkSendToEmail.Checked = ((txtFromEmail.Text + txtToEmail.Text) != ""); if (!chkSendToEmail.Checked) { txtFromEmail.Enabled = false; txtToEmail.Enabled = false; txtSubject.Enabled = false; chkAttachDocs.Enabled = false; chkCustomLayout.Visible = false; pnlCustomLayout.Visible = false; } else { // Enable or disable form EnableDisableForm(bfi.FormEmailTemplate); } } else { // Disable form by default EnableDisableForm(null); } } }
/// <summary> /// Initializes a new instance of the <see cref="SavedEventArgs"/> class. /// </summary> /// <param name="action"> /// The action. /// </param> public SavedEventArgs(SaveAction action) { this.Action = action; }
public SavedEventArgs(object entity, SaveAction saveAction) { this.item = entity; this.saveAction = saveAction; }
public void ProcessAction(SaveAction eventObject) { var viewModel = this.projectView.GetProjectViewModel(); if (viewModel != null) { var command = new UpdateProjectCommand( viewModel.Id, viewModel.Name, viewModel.Comment, viewModel.Reference, viewModel.StartDate, viewModel.EndDate, viewModel.Tasks, viewModel.OtherBenefits); this.OnUpdateProjectCommand(command); } }
private void ClearProperties() { // Clear actions save = null; checkin = null; checkout = null; undocheckout = null; // Clear security result ObjectManager.ClearProperties(); }
/// <summary> /// Initializes header actions. /// </summary> protected void InitHeaderActions() { menu.ActionsList.Clear(); // Add save action save = new SaveAction(Page); menu.ActionsList.Add(save); bool isAuthorized = CurrentUser.IsAuthorizedPerResource("cms.form", "EditForm") && ((formId > 0) && (EditedObject != null)); int attachCount = 0; if (isAuthorized) { // Get number of attachments InfoDataSet<MetaFileInfo> ds = MetaFileInfoProvider.GetMetaFiles(formId, FormObjectType.BIZFORM, MetaFileInfoProvider.OBJECT_CATEGORY_FORM_LAYOUT, null, null, "MetafileID", -1); attachCount = ds.Items.Count; string script = @" function UpdateAttachmentCount(count) { var counter = document.getElementById('attachmentCount'); if (counter != null) { if (count > 0) { counter.innerHTML = ' (' + count + ')'; } else { counter.innerHTML = ''; } } }"; ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "UpdateAttachmentScript_" + this.ClientID, script, true); // Register dialog scripts ScriptHelper.RegisterDialogScript(Page); } // Prepare metafile dialog URL string metaFileDialogUrl = ResolveUrl(@"~/CMSModules/AdminControls/Controls/MetaFiles/MetaFileDialog.aspx"); string query = string.Format("?objectid={0}&objecttype={1}", formId, FormObjectType.BIZFORM); metaFileDialogUrl += string.Format("{0}&category={1}&hash={2}", query, MetaFileInfoProvider.OBJECT_CATEGORY_FORM_LAYOUT, QueryHelper.GetHash(query)); // Init attachment button attachments = new HeaderAction() { ControlType = HeaderActionTypeEnum.LinkButton, Text = GetString("general.attachments") + string.Format("<span id='attachmentCount'>{0}</span>", (attachCount > 0) ? " (" + attachCount.ToString() + ")" : string.Empty), Tooltip = GetString("general.attachments"), OnClientClick = string.Format(@"if (modalDialog) {{modalDialog('{0}', 'Attachments', '700', '500');}}", metaFileDialogUrl) + " return false;", ImageUrl = isAuthorized ? GetImageUrl("Objects/CMS_MetaFile/attachment.png") : GetImageUrl("Objects/CMS_MetaFile/attachment_disabled.png"), Enabled = isAuthorized }; menu.ActionsList.Add(attachments); }
public void ProcessAction(SaveAction eventObject) { var viewModel = this.dealView.GetDealViewModel(); if (viewModel != null) { var command = new UpdateDealCommand( viewModel.Id, viewModel.Name, viewModel.Comment, viewModel.Reference, viewModel.StartDate, viewModel.EndDate); this.OnUpdateDealCommand(command); } }
protected void Page_Load(object sender, EventArgs e) { // Register a script file ScriptHelper.RegisterScriptFile(Page, "~/CMSModules/AdminControls/Controls/Class/layout.js"); // Add save action save = new SaveAction(Page); menu.ActionsList.Insert(0, save); // Register for action ComponentEvents.RequestEvents.RegisterForEvent(ComponentEvents.SAVE, lnkSave_Click); lblAvailableFields.Text = GetString("DocumentType_Edit_Form.AvailableFields"); btnGenerateLayout.Text = GetString("DocumentType_Edit_Form.btnGenerateLayout"); btnInsertLabel.Text = GetString("DocumentType_Edit_Form.btnInsertLabel"); btnInsertInput.Text = GetString("DocumentType_Edit_Form.btnInsertInput"); btnInsertValLabel.Text = GetString("DocumentType_Edit_Form.InsertValidationLabel"); btnInsertSubmitButton.Text = GetString("DocumentType_Edit_Form.InsertSubmitButton"); btnInsertVisibility.Text = GetString("DocumentType_Edit_Form.InsertVisibility"); chkCustomLayout.Text = GetString("DocumentType_Edit_Form.chkCustomLayout"); // Alert messages for JavaScript ltlAlertExist.Text = "<input type=\"hidden\" id=\"alertexist\" value=\"" + GetString("DocumentType_Edit_Form.AlertExist") + "\">"; ltlAlertExistFinal.Text = "<input type=\"hidden\" id=\"alertexistfinal\" value=\"" + GetString("DocumentType_Edit_Form.AlertExistFinal") + "\">"; ltlConfirmDelete.Text = "<input type=\"hidden\" id=\"confirmdelete\" value=\"" + GetString("DocumentType_Edit_Form.ConfirmDelete") + "\">"; // Element IDs ltlAvailFieldsElement.Text = ScriptHelper.GetScript("var lstAvailFieldsElem = document.getElementById('" + lstAvailableFields.ClientID + "'); "); ltlHtmlEditorID.Text = ScriptHelper.GetScript("var ckEditorID = '" + htmlEditor.ClientID + "'; "); if (!RequestHelper.IsPostBack()) { FillFieldsList(); LoadData(); chkCustomLayout.Checked = LayoutIsSet; } InitHTMLeditor(); // Load CSS style for editor area if any if (CssStyleSheetID > 0) { CssStylesheetInfo cssi = CssStylesheetInfoProvider.GetCssStylesheetInfo(CssStyleSheetID); if (cssi != null) { htmlEditor.EditorAreaCSS = CSSHelper.GetStylesheetUrl(cssi.StylesheetName); } } pnlCustomLayout.Visible = chkCustomLayout.Checked; // Custom table forms use default submit button in header actions plcSubmitButton.Visible = (FormType != FORMTYPE_CUSTOMTABLE); // Display button for inserting visibility macros only if enabled and the class is 'cms.user' if (IsAlternative) { DataClassInfo dci = DataClassInfoProvider.GetDataClass(DataClassID); if ((dci != null) && (dci.ClassName.ToLowerCSafe() == "cms.user")) { plcVisibility.Visible = true; } } }
protected void Page_Load(object sender, EventArgs e) { RegisterResizeHeaders(); CMSContext.ViewMode = ViewModeEnum.MasterPage; previewState = GetPreviewStateFromCookies(MASTERPAGE); // Keep current user user = CMSContext.CurrentUser; // Get document node tree = new TreeProvider(user); node = CMSContext.EditedObject as TreeNode; // Register the dialog script ScriptHelper.RegisterDialogScript(Page); // Register save changes ScriptHelper.RegisterSaveChanges(Page); // Save changes support bool confirmChanges = SettingsKeyProvider.GetBoolValue(CMSContext.CurrentSiteName + ".CMSConfirmChanges"); string script = string.Empty; if (confirmChanges) { script = "var confirmLeave='" + ResHelper.GetString("Content.ConfirmLeave", user.PreferredUICultureCode) + "'; \n"; } else { script += "confirmChanges = false;"; } ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "saveChangesScript", ScriptHelper.GetScript(script)); try { if (node != null) { CMSContext.CurrentPageInfo = PageInfoProvider.GetPageInfo(CMSContext.CurrentSiteName, node.NodeAliasPath, node.DocumentCulture, null, false); // Title string title = CMSContext.CurrentTitle; if (!string.IsNullOrEmpty(title)) { title = "<title>" + title + "</title>"; } // Body class string bodyCss = CMSContext.CurrentBodyClass; if (bodyCss != null && bodyCss.Trim() != "") { bodyCss = "class=\"" + bodyCss + "\""; } else { bodyCss = ""; } // Metadata string meta = "<meta http-equiv=\"pragma\" content=\"no-cache\" />"; string description = CMSContext.CurrentDescription; if (description != "") { meta += "<meta name=\"description\" content=\"" + description + "\" />"; } string keywords = CMSContext.CurrentKeyWords; if (keywords != "") { meta += "<meta name=\"keywords\" content=\"" + keywords + "\" />"; } // Site style sheet string cssSiteSheet = ""; int stylesheetId = CMSContext.CurrentPageInfo.DocumentStylesheetID; CssStylesheetInfo cssInfo = CssStylesheetInfoProvider.GetCssStylesheetInfo((stylesheetId > 0) ? stylesheetId : CMSContext.CurrentSite.SiteDefaultStylesheetID); if (cssInfo != null) { cssSiteSheet = CSSHelper.GetCSSFileLink(CSSHelper.GetStylesheetUrl(cssInfo.StylesheetName)); } // Theme CSS files string themeCssFiles = ""; if (cssInfo != null) { try { string directory = URLHelper.GetPhysicalPath(string.Format("~/App_Themes/{0}/", cssInfo.StylesheetName)); if (Directory.Exists(directory)) { foreach (string file in Directory.GetFiles(directory, "*.css")) { themeCssFiles += CSSHelper.GetCSSFileLink(CSSHelper.GetPhysicalCSSUrl(cssInfo.StylesheetName, Path.GetFileName(file))); } } } catch { } } // Add values to page mHead = FormatHTML(HighlightHTML(title + meta + cssSiteSheet + themeCssFiles), 2); mBody = bodyCss; } } catch { ShowError(GetString("MasterPage.PageEditErr")); } LoadData(); // Add save action SaveAction save = new SaveAction(Page); save.CommandArgument = ComponentEvents.SAVE_DATA; save.CommandName = ComponentEvents.SAVE_DATA; headerActions.ActionsList.Add(save); if (pti != null) { // Edit layout HeaderAction action = new HeaderAction { Text = GetString("content.ui.pagelayout"), Tooltip = GetString("pageplaceholder.editlayouttooltip"), OnClientClick = "EditLayout();return false;", ImageUrl = GetImageUrl("CMSModules/CMS_PortalEngine/Edit.png") }; headerActions.ActionsList.Add(action); // Edit page properties action action = new HeaderAction { Text = GetString("PageProperties.EditTemplateProperties"), Tooltip = GetString("PageProperties.EditTemplateProperties"), OnClientClick = "modalDialog('" + ResolveUrl("~/CMSModules/PortalEngine/UI/PageTemplates/PageTemplate_Edit.aspx") + "?templateid=" + pti.PageTemplateId + "&nobreadcrumbs=1&dialog=1', 'TemplateSelection', 850, 680, false);return false;", ImageUrl = GetImageUrl("CMSModules/CMS_Content/Template/edit.png") }; CMSPagePlaceholder.RegisterEditLayoutScript(this, pti.PageTemplateId, node.NodeAliasPath, null); headerActions.ActionsList.Add(action); // Preview HeaderAction preview = new HeaderAction { ControlType = HeaderActionTypeEnum.LinkButton, Text = GetString("general.preview"), OnClientClick = "performToolbarAction('split');return false;", ImageUrl = GetImageUrl("CMSModules/CMS_Content/EditMenu/Preview.png"), SmallImageUrl = GetImageUrl("CMSModules/CMS_Content/EditMenu/16/Preview.png"), Visible = ((previewState == 0) && !CMSContext.DisplaySplitMode), Tooltip = GetString("preview.tooltip") }; headerActions.ActionsList.Add(preview); headerActions.ActionPerformed += new CommandEventHandler(headerActions_ActionPerformed); } RegisterInitScripts(pnlBody.ClientID, pnlMenu.ClientID, false); }
public virtual bool Save(string fileName, SaveAction saveAction) { if (!Directory.Exists(this.RootDirectory)) Directory.CreateDirectory(this.RootDirectory); string str = Path.Combine(this.RootDirectory, fileName); if (System.IO.File.Exists(str)) System.IO.File.Copy(str, str + "_Backup", true); try { byte[] buffer = new byte[40960]; using (MemoryStream memoryStream = new MemoryStream(buffer)) { using (BinaryWriter writer = new BinaryWriter((Stream) memoryStream)) { writer.Write(DateTime.Now.ToFileTime()); saveAction(writer); if (memoryStream.Length < 40960L) { long length = 40960L - memoryStream.Length; writer.Write(new byte[length]); } else if (memoryStream.Length > 40960L) throw new InvalidOperationException("Save file greater than the imposed limit!"); } } using (FileStream fileStream = new FileStream(str, FileMode.Create, FileAccess.Write, FileShare.Read)) { using (BinaryWriter binaryWriter = new BinaryWriter((Stream) fileStream)) binaryWriter.Write(buffer); } return true; } catch (Exception ex) { PCSaveDevice.Log("Error while saving : " + (object) ex); } return false; }
protected override void OnPreRender(EventArgs e) { base.OnPreRender(e); bool allowed = CheckModifyPermissions(false); HeaderAction processAction = new HeaderAction() { OnClientClick = "if (confirm(" + ScriptHelper.GetString(GetString("translationservice.confirmprocesstranslations")) + ")) { " + ControlsHelper.GetPostBackEventReference(btnImportTranslations, null) + " }", Tooltip = GetString("translationservice.importtranslationstooltip"), Text = GetString("translationservice.importtranslations"), Enabled = allowed }; processAction.Enabled = (SubmissionInfo != null) && ((SubmissionInfo.SubmissionStatus == TranslationStatusEnum.TranslationReady) || (SubmissionInfo.SubmissionStatus == TranslationStatusEnum.TranslationCompleted) || (SubmissionInfo.SubmissionStatus == TranslationStatusEnum.ProcessingError)); processAction.ImageUrl = GetImageUrl("Design/Controls/UniGrid/Actions/Synchronize" + (processAction.Enabled ? "" : "Disabled") + ".png"); HeaderAction resubmitAction = new HeaderAction() { CommandName = "resubmit", Tooltip = GetString("translationservice.resubmittooltip"), Text = GetString("translationservice.resubmit"), Enabled = allowed }; resubmitAction.Enabled = (SubmissionInfo != null) && ((SubmissionInfo.SubmissionStatus == TranslationStatusEnum.WaitingForTranslation) || (SubmissionInfo.SubmissionStatus == TranslationStatusEnum.SubmissionError)); resubmitAction.ImageUrl = GetImageUrl("Design/Controls/UniGrid/Actions/Rebuild" + (resubmitAction.Enabled ? "" : "Disabled") + ".png"); HeaderAction updateAction = new HeaderAction() { CommandName = "update", Tooltip = GetString("translationservice.updateandresubmittooltip"), Text = GetString("translationservice.updateandresubmit"), Enabled = allowed }; updateAction.Enabled = (SubmissionInfo != null) && ((SubmissionInfo.SubmissionStatus == TranslationStatusEnum.WaitingForTranslation) || (SubmissionInfo.SubmissionStatus == TranslationStatusEnum.SubmissionError)); updateAction.ImageUrl = GetImageUrl("Design/Controls/UniGrid/Actions/Rebuild" + (updateAction.Enabled ? "" : "Disabled") + ".png"); HeaderAction cancelAction = new HeaderAction() { CommandName = "cancel", Tooltip = GetString("translationservice.cancelsubmissiontooltip"), Text = GetString("translationservice.cancelsubmission"), Enabled = allowed }; cancelAction.Enabled = (SubmissionInfo != null) && (SubmissionInfo.SubmissionStatus == TranslationStatusEnum.WaitingForTranslation); cancelAction.ImageUrl = GetImageUrl("Design/Controls/UniGrid/Actions/Undo" + (cancelAction.Enabled ? "" : "Disabled") + ".png"); HeaderAction saveAction = new SaveAction(this.Page); saveAction.Enabled = allowed; List<HeaderAction> actions = this.CurrentMaster.HeaderActions.ActionsList; actions.Add(saveAction); actions.Add(updateAction); actions.Add(resubmitAction); actions.Add(processAction); actions.Add(cancelAction); CurrentMaster.HeaderActions.ReloadData(); ScriptHelper.RegisterClientScriptBlock(this.Page, typeof(string), "ShowUploadSuccess", "function ShowUploadSuccess() { " + ControlsHelper.GetPostBackEventReference(btnShowMessage, null) + " }", true); }
/// <summary> /// Initializes the header actions. /// </summary> private void InitHeaderActions() { if (Product is TreeNode) { // Initialize edit menu editMenuElem.Visible = true; editMenuElem.StopProcessing = false; } else { // Initialize header actions pnlHeaderActions.Visible = true; headerActionsElem.StopProcessing = false; SaveAction saveAction = new SaveAction(); if ((DocumentManager != null) && DocumentManager.ConfirmChanges) { saveAction.OnClientClick = DocumentManager.GetAllowSubmitScript(); } headerActionsElem.AddAction(saveAction); if (FormMode == FormModeEnum.Insert) { headerActionsElem.AddAction(new HeaderAction { Text = GetString("editmenu.iconsaveandanother"), Tooltip = GetString("editmenu.iconsaveandanother"), Enabled = Enabled, CommandName = "savecreateanother" }); } headerActionsElem.ActionPerformed += (sender, args) => HandlePostbackCommand(args.CommandName); } }
protected void Page_Load(object sender, EventArgs e) { previewState = GetPreviewStateFromCookies(MASTERPAGE); // Keep current user user = MembershipContext.AuthenticatedUser; // Get document node tree = new TreeProvider(user); node = UIContext.EditedObject as TreeNode; // Register the dialog script ScriptHelper.RegisterDialogScript(Page); // Register save changes ScriptHelper.RegisterSaveChanges(Page); // Save changes support bool confirmChanges = SettingsKeyInfoProvider.GetBoolValue(SiteContext.CurrentSiteName + ".CMSConfirmChanges"); string script = string.Empty; if (confirmChanges) { script = "CMSContentManager.confirmLeave=" + ScriptHelper.GetString(ResHelper.GetString("Content.ConfirmLeave", user.PreferredUICultureCode), true, false) + "; \n"; script += "CMSContentManager.confirmLeaveShort=" + ScriptHelper.GetString(ResHelper.GetString("Content.ConfirmLeaveShort", user.PreferredUICultureCode), true, false) + "; \n"; } else { script += "CMSContentManager.confirmChanges = false;"; } ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "saveChangesScript", script, true); try { if (node != null) { DocumentContext.CurrentPageInfo = PageInfoProvider.GetPageInfo(node.NodeSiteName, node.NodeAliasPath, node.DocumentCulture, null, node.NodeID, false); // Title string title = DocumentContext.CurrentTitle; if (!string.IsNullOrEmpty(title)) { title = "<title>" + title + "</title>"; } // Body class string bodyCss = DocumentContext.CurrentBodyClass; // Remove bootstrap default class bodyCss = bodyCss.Replace(" cms-bootstrap", String.Empty); if (bodyCss != null && bodyCss.Trim() != "") { bodyCss = "class=\"" + bodyCss + "\""; } else { bodyCss = ""; } // Metadata string meta = "<meta http-equiv=\"pragma\" content=\"no-cache\" />"; string description = DocumentContext.CurrentDescription; if (description != "") { meta += "<meta name=\"description\" content=\"" + description + "\" />"; } string keywords = DocumentContext.CurrentKeyWords; if (keywords != "") { meta += "<meta name=\"keywords\" content=\"" + keywords + "\" />"; } // Site style sheet string cssSiteSheet = ""; int stylesheetId = DocumentContext.CurrentPageInfo.DocumentStylesheetID; CssStylesheetInfo cssInfo = CssStylesheetInfoProvider.GetCssStylesheetInfo((stylesheetId > 0) ? stylesheetId : SiteContext.CurrentSite.SiteDefaultStylesheetID); if (cssInfo != null) { cssSiteSheet = CSSHelper.GetCSSFileLink(CSSHelper.GetStylesheetUrl(cssInfo.StylesheetName)); } // Theme CSS files string themeCssFiles = ""; if (cssInfo != null) { try { string directory = URLHelper.GetPhysicalPath(string.Format("~/App_Themes/{0}/", cssInfo.StylesheetName)); if (Directory.Exists(directory)) { foreach (string file in Directory.GetFiles(directory, "*.css")) { themeCssFiles += CSSHelper.GetCSSFileLink(CSSHelper.GetPhysicalCSSUrl(cssInfo.StylesheetName, Path.GetFileName(file))); } } } catch { } } // Add values to page mHead = FormatHTML(HighlightHTML(title + meta + cssSiteSheet + themeCssFiles), 2); mBody = bodyCss; } } catch { ShowError(GetString("MasterPage.PageEditErr")); } LoadData(); // Add save action SaveAction save = new SaveAction(); save.CommandArgument = ComponentEvents.SAVE_DATA; save.CommandName = ComponentEvents.SAVE_DATA; headerActions.ActionsList.Add(save); if (pti != null) { // Disable buttons for no-template bool actionsEnabled = (pti.PageTemplateId > 0); // Edit layout HeaderAction action = new HeaderAction { Text = GetString("content.ui.pagelayout"), Tooltip = GetString("pageplaceholder.editlayouttooltip"), OnClientClick = "EditLayout();return false;", Enabled = actionsEnabled }; headerActions.ActionsList.Add(action); string elemUrl = UIContextHelper.GetElementDialogUrl("cms.design", "PageTemplate.EditPageTemplate", pti.PageTemplateId); // Edit page properties action action = new HeaderAction { Text = GetString("PageProperties.EditTemplateProperties"), Tooltip = GetString("PageProperties.EditTemplateProperties"), OnClientClick = "modalDialog('" + elemUrl + "', 'TemplateSelection', '85%', '85%', false);return false;", Enabled = actionsEnabled }; CMSPagePlaceholder.RegisterEditLayoutScript(this, pti.PageTemplateId, node.NodeAliasPath, null); headerActions.ActionsList.Add(action); // Preview HeaderAction preview = new HeaderAction { Text = GetString("general.preview"), OnClientClick = "performToolbarAction('split');return false;", Visible = ((previewState == 0) && !UIContext.DisplaySplitMode), Tooltip = GetString("preview.tooltip") }; headerActions.ActionsList.Add(preview); headerActions.ActionPerformed += headerActions_ActionPerformed; } RegisterInitScripts(pnlBody.ClientID, pnlMenu.ClientID, false); }
private void ReloadMenu() { if (StopProcessing) { return; } // Raise event handler RaiseOnBeforeReloadMenu(); // Handle several reloads ClearProperties(); var showWorkflowButtons = HandleWorkflow; if (!HideStandardButtons) { if (Step == null) { // Do not handle workflow HandleWorkflow = false; } bool hideSave = false; // If content should be refreshed if (DocumentManager.RefreshActionContent) { // Display action message if (Step != null) { WorkflowActionInfo action = WorkflowActionInfoProvider.GetWorkflowActionInfo(Step.StepActionID); string name = (action != null) ? action.ActionDisplayName : Step.StepDisplayName; string str = (action != null) ? "workflow.actioninprogress" : "workflow.stepinprogress"; string text = string.Format(ResHelper.GetString(str, ResourceCulture), HTMLHelper.HTMLEncode(ResHelper.LocalizeString(name, ResourceCulture))); text = ScriptHelper.GetLoaderInlineHtml(Page, text); InformationText = text; EnsureRefreshScript(); hideSave = true; } } // Handle save action if (ShowSave && !hideSave) { save = new SaveAction { OnClientClick = RaiseGetClientValidationScript(ComponentEvents.SAVE, DocumentManager.ConfirmChanges ? DocumentManager.GetAllowSubmitScript() : null), Tooltip = ResHelper.GetString("EditMenu.Save", ResourceCulture) }; // If not allowed to save, disable the save item if (!AllowSave) { save.OnClientClick = null; save.Enabled = false; } // New version if (DocumentManager.IsActionAllowed(DocumentComponentEvents.CREATE_VERSION)) { newVersion = new HeaderAction { Text = ResHelper.GetString("EditMenu.NewVersionIcon", ResourceCulture), Tooltip = ResHelper.GetString("EditMenu.NewVersion", ResourceCulture), EventName = DocumentComponentEvents.CREATE_VERSION }; } } // Document update if (DocumentManager.Mode == FormModeEnum.Update) { if (Node != null) { string submitScript = DocumentManager.GetSubmitScript(); #region "Workflow actions" if (HandleWorkflow) { // Check-out action if (ShowCheckOut && DocumentManager.IsActionAllowed(DocumentComponentEvents.CHECKOUT)) { checkout = new DocumentCheckOutAction(); } // Undo check-out action if (ShowUndoCheckOut && DocumentManager.IsActionAllowed(DocumentComponentEvents.UNDO_CHECKOUT)) { undoCheckout = new DocumentUndoCheckOutAction { OnClientClick = RaiseGetClientValidationScript(DocumentComponentEvents.UNDO_CHECKOUT, "if(!confirm(" + ScriptHelper.GetString(ResHelper.GetString("EditMenu.UndoCheckOutConfirmation", ResourceCulture)) + ")) { return false; }"), }; } // Check-in action if (ShowCheckIn && DocumentManager.IsActionAllowed(DocumentComponentEvents.CHECKIN)) { checkin = new DocumentCheckInAction { OnClientClick = RaiseGetClientValidationScript(DocumentComponentEvents.CHECKIN, submitScript), }; // Add check-in comment AddCommentAction(DocumentComponentEvents.CHECKIN, checkin); } // Approve action if (DocumentManager.IsActionAllowed(DocumentComponentEvents.APPROVE)) { if ((Step == null) || Step.StepIsEdit) { if (ShowSubmitToApproval) { approve = new DocumentApproveAction { Text = ResHelper.GetString("EditMenu.IconSubmitToApproval", ResourceCulture), Tooltip = ResHelper.GetString("EditMenu.SubmitToApproval", ResourceCulture), OnClientClick = RaiseGetClientValidationScript(DocumentComponentEvents.APPROVE, submitScript) }; } } else { if (ShowApprove) { approve = new DocumentApproveAction { OnClientClick = RaiseGetClientValidationScript(DocumentComponentEvents.APPROVE, submitScript) }; } } } // Reject action if (ShowReject && DocumentManager.IsActionAllowed(DocumentComponentEvents.REJECT)) { var prevSteps = WorkflowManager.GetPreviousSteps(Node); int prevStepsCount = prevSteps.Count; if (prevStepsCount > 0) { reject = new DocumentRejectAction { OnClientClick = RaiseGetClientValidationScript(DocumentComponentEvents.REJECT, submitScript) }; // For workflow managers allow reject to specified step if (WorkflowManager.CanUserManageWorkflow(CurrentUser, Node.NodeSiteName)) { if (prevStepsCount > 1) { foreach (var s in prevSteps) { reject.AlternativeActions.Add(new DocumentRejectAction { Text = string.Format(ResHelper.GetString("EditMenu.RejectTo", ResourceCulture), HTMLHelper.HTMLEncode(ResHelper.LocalizeString(s.StepDisplayName, ResourceCulture))), OnClientClick = RaiseGetClientValidationScript(DocumentComponentEvents.REJECT, submitScript), CommandArgument = s.RelatedHistoryID.ToString() }); } } } // Add reject comment AddCommentAction(DocumentComponentEvents.REJECT, reject); } } // Get next step info List<WorkflowStepInfo> steps = DocumentManager.NextSteps; int stepsCount = steps.Count; WorkflowInfo workflow = DocumentManager.Workflow; List<WorkflowTransitionInfo> transitions = null; // Handle multiple next steps if (approve != null) { string actionName = DocumentComponentEvents.APPROVE; bool publishStepVisible = false; // Get next approval step info var approveSteps = steps.FindAll(s => !s.StepIsArchived); int approveStepsCount = approveSteps.Count; if (approveStepsCount > 0) { var nextS = approveSteps[0]; // Only one next step if (approveStepsCount == 1) { if (nextS.StepIsPublished) { publishStepVisible = true; actionName = DocumentComponentEvents.PUBLISH; approve.Text = ResHelper.GetString("EditMenu.IconPublish", ResourceCulture); approve.Tooltip = ResHelper.GetString("EditMenu.Publish", ResourceCulture); } // There are also archived steps if (stepsCount > 1) { // Set command argument approve.CommandArgument = nextS.StepID.ToString(); } // Process action appearance ProcessAction(approve, Step, nextS); } // Multiple next steps else { // Check if not all steps publish steps if (approveSteps.Exists(s => !s.StepIsPublished)) { approve.Tooltip = ResHelper.GetString("EditMenu.ApproveMultiple", ResourceCulture); } else { actionName = DocumentComponentEvents.PUBLISH; approve.Text = ResHelper.GetString("EditMenu.IconPublish", ResourceCulture); approve.Tooltip = ResHelper.GetString("EditMenu.ApproveMultiple", ResourceCulture); } // Make action inactive approve.Inactive = true; // Process action appearance ProcessAction(approve, Step, null); string itemText = (Step == null) || Step.StepIsEdit ? "EditMenu.SubmitTo" : "EditMenu.ApproveTo"; string itemDesc = (Step == null) || Step.StepIsEdit ? "EditMenu.SubmitToApproval" : "EditMenu.Approve"; foreach (var s in approveSteps) { DocumentApproveAction app = new DocumentApproveAction { Text = string.Format(ResHelper.GetString(itemText, ResourceCulture), HTMLHelper.HTMLEncode(ResHelper.LocalizeString(s.StepDisplayName, ResourceCulture))), Tooltip = ResHelper.GetString(itemDesc, ResourceCulture), OnClientClick = RaiseGetClientValidationScript(DocumentComponentEvents.APPROVE, submitScript), CommandArgument = s.StepID.ToString() }; if (s.StepIsPublished) { publishStepVisible = true; app.Text = string.Format(ResHelper.GetString("EditMenu.PublishTo", ResourceCulture), HTMLHelper.HTMLEncode(ResHelper.LocalizeString(s.StepDisplayName, ResourceCulture))); app.Tooltip = ResHelper.GetString("EditMenu.Publish", ResourceCulture); } // Process action appearance ProcessAction(app, Step, s); // Add step approve.AlternativeActions.Add(app); } } // Display direct publish button if (WorkflowManager.CanUserManageWorkflow(CurrentUser, Node.NodeSiteName) && !publishStepVisible && Step.StepAllowPublish) { // Add approve action as a alternative action if ((approve.AlternativeActions.Count == 0) && !nextS.StepIsPublished) { // Make action inactive approve.Tooltip = ResHelper.GetString("EditMenu.ApproveMultiple", ResourceCulture); approve.Inactive = true; // Add approve action string itemText = Step.StepIsEdit ? "EditMenu.SubmitTo" : "EditMenu.ApproveTo"; string itemDesc = Step.StepIsEdit ? "EditMenu.SubmitToApproval" : "EditMenu.Approve"; DocumentApproveAction app = new DocumentApproveAction { Text = string.Format(ResHelper.GetString(itemText, ResourceCulture), HTMLHelper.HTMLEncode(ResHelper.LocalizeString(nextS.StepDisplayName, ResourceCulture))), Tooltip = ResHelper.GetString(itemDesc, ResourceCulture), OnClientClick = RaiseGetClientValidationScript(DocumentComponentEvents.APPROVE, submitScript), CommandArgument = nextS.StepID.ToString() }; // Process action appearance ProcessAction(app, Step, nextS); approve.AlternativeActions.Add(app); } // Add direct publish action publish = new DocumentPublishAction { OnClientClick = RaiseGetClientValidationScript(DocumentComponentEvents.PUBLISH, submitScript), }; // Process action appearance ProcessAction(approve, Step, nextS); approve.AlternativeActions.Add(publish); } // Add approve comment AddCommentAction(actionName, approve); } else { bool displayAction = false; if (!workflow.IsBasic && (Step != null) && !Step.StepAllowBranch) { // Transition exists, but condition doesn't match transitions = WorkflowManager.GetStepTransitions(Step, WorkflowTransitionTypeEnum.Manual); if (transitions.Count > 0) { WorkflowStepInfo s = WorkflowStepInfoProvider.GetWorkflowStepInfo(transitions[0].TransitionEndStepID); if (!s.StepIsArchived) { // Publish text if (s.StepIsPublished) { approve.Text = ResHelper.GetString("EditMenu.IconPublish", ResourceCulture); approve.Tooltip = ResHelper.GetString("EditMenu.Publish", ResourceCulture); } // Inform user displayAction = true; approve.Enabled = false; // Process action appearance ProcessAction(approve, Step, null); } } } if (!displayAction) { // There is not next step approve = null; } } } // Archive action if ((ShowArchive || ForceArchive) && DocumentManager.IsActionAllowed(DocumentComponentEvents.ARCHIVE)) { // Get next archive step info var archiveSteps = steps.FindAll(s => s.StepIsArchived); int archiveStepsCount = archiveSteps.Count; archive = new DocumentArchiveAction { OnClientClick = RaiseGetClientValidationScript(DocumentComponentEvents.ARCHIVE, "if(!confirm(" + ScriptHelper.GetString(ResHelper.GetString("EditMenu.ArchiveConfirmation", ResourceCulture)) + ")) { return false; }" + submitScript), }; // Multiple archive steps if (archiveStepsCount > 1) { // Make action inactive archive.Tooltip = ResHelper.GetString("EditMenu.ArchiveMultiple", ResourceCulture); archive.OnClientClick = null; archive.Inactive = true; const string itemText = "EditMenu.ArchiveTo"; const string itemDesc = "EditMenu.Archive"; foreach (var s in archiveSteps) { DocumentArchiveAction arch = new DocumentArchiveAction { Text = string.Format(ResHelper.GetString(itemText, ResourceCulture), HTMLHelper.HTMLEncode(ResHelper.LocalizeString(s.StepDisplayName, ResourceCulture))), Tooltip = ResHelper.GetString(itemDesc, ResourceCulture), OnClientClick = RaiseGetClientValidationScript(DocumentComponentEvents.ARCHIVE, "if(!confirm(" + ScriptHelper.GetString(ResHelper.GetString("EditMenu.ArchiveConfirmation", ResourceCulture)) + ")) { return false; }" + submitScript), CommandArgument = s.StepID.ToString() }; // Process action appearance ProcessAction(arch, Step, s); // Add step archive.AlternativeActions.Add(arch); } // Add archive comment AddCommentAction(DocumentComponentEvents.ARCHIVE, archive); } else if (archiveStepsCount == 1) { var nextS = archiveSteps[0]; // There are also approve steps if (stepsCount > 1) { // Set command argument archive.CommandArgument = nextS.StepID.ToString(); } // Process action appearance ProcessAction(archive, Step, nextS); // Add archive comment AddCommentAction(DocumentComponentEvents.ARCHIVE, archive); } else { bool displayAction = ForceArchive; if (!workflow.IsBasic && !Step.StepAllowBranch) { // Transition exists, but condition doesn't match if (transitions == null) { transitions = WorkflowManager.GetStepTransitions(Step, WorkflowTransitionTypeEnum.Manual); } if (transitions.Count > 0) { WorkflowStepInfo s = WorkflowStepInfoProvider.GetWorkflowStepInfo(transitions[0].TransitionEndStepID); if (s.StepIsArchived) { // Inform user displayAction = true; archive.Enabled = false; // Process action appearance ProcessAction(archive, Step, null); } } } if (!displayAction) { // There is not next step archive = null; } else { // Add archive comment AddCommentAction(DocumentComponentEvents.ARCHIVE, archive); } } } } // Display Apply workflow button if user has permission to manage workflow and the button should be displayed and document is not linked if (DisplayApplyWorkflowButton(showWorkflowButtons)) { ScriptHelper.RegisterDialogScript(Page); applyWorkflow = new HeaderAction { Text = ResHelper.GetString("WorkflowProperties.Apply", ResourceCulture), Tooltip = ResHelper.GetString("EditMenu.WorkflowApply", ResourceCulture), OnClientClick = string.Format("modalDialog('{0}','ApplyWorkflow', 770, 200, null, null, true); return false;", URLHelper.ResolveUrl("~/CMSModules/Workflows/Pages/ApplyWorkflow.aspx?documentid=" + Node.DocumentID)), ButtonStyle = ButtonStyle.Default }; } #endregion // Delete action if (AllowSave && ShowDelete) { delete = new DeleteAction { OnClientClick = RaiseGetClientValidationScript(ComponentEvents.DELETE, "Delete_" + ClientID + "(" + NodeID + "); return false;") }; } // Properties action if (ShowProperties) { prop = new HeaderAction { Text = ResHelper.GetString("EditMenu.IconProperties", ResourceCulture), Tooltip = ResHelper.GetString("EditMenu.Properties", ResourceCulture), OnClientClick = "Properties(" + NodeID + "); return false;", ButtonStyle = ButtonStyle.Default }; } } } // Ensure create another action else if (DocumentManager.Mode == FormModeEnum.Insert) { if (AllowSave && ShowCreateAnother) { string saveAnotherScript = DocumentManager.GetSaveAnotherScript(); saveAnother = new SaveAction { RegisterShortcutScript = false, Text = ResHelper.GetString("editmenu.iconsaveandanother", ResourceCulture), Tooltip = ResHelper.GetString("EditMenu.SaveAndAnother", ResourceCulture), OnClientClick = RaiseGetClientValidationScript(ComponentEvents.SAVE, (DocumentManager.ConfirmChanges ? DocumentManager.GetAllowSubmitScript() : "") + saveAnotherScript), CommandArgument = "another" }; } } // Ensure spell check action if (AllowSave && ShowSave && ShowSpellCheck) { spellcheck = new HeaderAction { Text = ResHelper.GetString("EditMenu.IconSpellCheck", ResourceCulture), Tooltip = ResHelper.GetString("EditMenu.SpellCheck", ResourceCulture), OnClientClick = "SpellCheck_" + ClientID + "(spellURL); return false;", RedirectUrl = "#", ButtonStyle = ButtonStyle.Default }; } if (AllowSave && ShowSaveAndClose) { string saveAndCloseScript = DocumentManager.GetSaveAndCloseScript(); saveAndClose = new SaveAction { RegisterShortcutScript = false, Text = ResHelper.GetString("editmenu.iconsaveandclose", ResourceCulture), Tooltip = ResHelper.GetString("EditMenu.SaveAndClose", ResourceCulture), OnClientClick = RaiseGetClientValidationScript(ComponentEvents.SAVE, (DocumentManager.ConfirmChanges ? DocumentManager.GetAllowSubmitScript() : "") + saveAndCloseScript), CommandArgument = "saveandclose" }; } } // Add actions in correct order menu.ActionsList.Clear(); AddAction(saveAndClose); AddAction(save); AddAction(saveAnother); AddAction(newVersion); if (HandleWorkflow) { AddAction(checkout); AddAction(undoCheckout); AddAction(checkin); AddAction(reject); AddAction(approve); AddAction(archive); } AddAction(spellcheck); AddAction(delete); AddAction(prop); AddAction(convert); AddAction(applyWorkflow); // Show temporary to set correct visibility of checkbox for sending e-mails plcControls.Visible = true; // Set e-mails checkbox chkEmails.Visible = WorkflowManager.CanUserManageWorkflow(CurrentUser, DocumentManager.SiteName) && ((approve != null) || (reject != null) || (archive != null)); if (chkEmails.Visible) { chkEmails.ResourceString = ResHelper.GetString("WorfklowProperties.SendMail", ResourceCulture); if (!DocumentManager.Workflow.SendEmails(DocumentManager.SiteName, WorkflowEmailTypeEnum.Unknown)) { chkEmails.Enabled = false; chkEmails.ToolTip = ResHelper.GetString("wf.emails.disabled", ResourceCulture); } } // Hide placeholder if there is no visible functional control plcControls.Visible = pnlRight.Controls.Cast<Control>().Any(c => (c.Visible && !(c is LiteralControl))); // Add extra actions if (mExtraActions != null) { foreach (HeaderAction action in mExtraActions) { AddAction(action); } } // Set the information text if (!String.IsNullOrEmpty(InformationText)) { lblInfo.Text = InformationText; lblInfo.CssClass = "LeftAlign EditMenuInfo"; lblInfo.Visible = true; } }
protected override void OnPreRender(EventArgs e) { string dataCodeName = string.IsNullOrEmpty(ManageDataCodeName) ? QueryHelper.GetString("dataCodeName", string.Empty) : ManageDataCodeName; string deleteScript = string.Format("modalDialog('{0}?statcodename={1}','AnalyticsManageData',{2},{3});", ResolveUrl("~/CMSModules/Reporting/WebAnalytics/Analytics_ManageData.aspx"), dataCodeName, AnalyticsHelper.MANAGE_WINDOW_WIDTH, AnalyticsHelper.MANAGE_WINDOW_HEIGHT); string printScript = string.Format("myModalDialog('{0}?reportname={1}¶meters={2}&UILang={3}','PrintReport {1}',800,700);return false", ResolveUrl(PrintPageURL), ReportName, AnalyticsHelper.GetQueryStringParameters(ReportParameters), CultureInfo.CurrentUICulture.IetfLanguageTag); string subscriptionScript = String.Format("modalDialog('{0}?reportname={1}¶meters={2}&interval={3}','Subscription',{4},{5});return false", ResolveUrl("~/CMSModules/Reporting/Dialogs/EditSubscription.aspx"), ReportName, AnalyticsHelper.GetQueryStringParameters(ReportParameters), HitsIntervalEnumFunctions.HitsConversionToString(SelectedInterval), AnalyticsHelper.SUBSCRIPTION_WINDOW_WIDTH, AnalyticsHelper.SUBSCRIPTION_WINDOW_HEIGHT); string refreshScript = "function RefreshPage() {" + ControlsHelper.GetPostBackEventReference(this, "") + "};"; ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "RefreshScript", ScriptHelper.GetScript(refreshScript)); // Register special script for print window ScriptHelper.RegisterPrintDialogScript(Page); headerActions.PanelCssClass = PanelCssClass; // Create header actions SaveAction save = new SaveAction(Page); headerActions.ActionsList.Add(save); // Print HeaderAction print = new HeaderAction { ControlType = HeaderActionTypeEnum.LinkButton, Text = GetString("Analytics_Report.Print"), SmallImageUrl = GetImageUrl("General/printSmall.png"), OnClientClick = printScript }; headerActions.ActionsList.Add(print); CurrentUserInfo cui = CMSContext.CurrentUser; // Manage data if (cui.IsAuthorizedPerResource("CMS.WebAnalytics", "ManageData") && DisplayManageData) { HeaderAction delete = new HeaderAction { ControlType = HeaderActionTypeEnum.LinkButton, Text = GetString("Analytics_Report.ManageData"), SmallImageUrl = GetImageUrl("CMSModules/CMS_Reporting/managedataSmall.png"), OnClientClick = deleteScript }; headerActions.ActionsList.Add(delete); } // Report subscription enabled test GeneralizedInfo ri = ModuleCommands.ReportingGetReportInfo(ReportName); if (ri != null) { bool enableSubscription = ValidationHelper.GetBoolean(ri.GetValue("ReportEnableSubscription"), true); // Show enable subscription only for users with subscribe or modify. enableSubscription &= (cui.IsAuthorizedPerResource("cms.reporting", "subscribe") || cui.IsAuthorizedPerResource("cms.reporting", "modify")); if (enableSubscription) { // Subscription HeaderAction subscription = new HeaderAction { ControlType = HeaderActionTypeEnum.LinkButton, Text = GetString("notifications.subscribe"), SmallImageUrl = GetImageUrl("CMSModules/CMS_Reporting/Subscription.png"), OnClientClick = subscriptionScript }; headerActions.ActionsList.Add(subscription); } } base.OnPreRender(e); }
private void ClearProperties() { // Clear actions save = null; saveAnother = null; saveAndClose = null; approve = null; reject = null; checkin = null; checkout = null; undoCheckout = null; archive = null; delete = null; prop = null; spellcheck = null; publish = null; newVersion = null; applyWorkflow = null; mStep = null; // Clear security result DocumentManager.ClearProperties(); }
/// <summary> /// Init menu /// </summary> private void InitHeaderActions() { // Save action SaveAction save = new SaveAction(Page); headerActions.ActionsList.Add(save); // Preview HeaderAction preview = new HeaderAction { Text = GetString("general.preview"), OnClientClick = "performToolbarAction('split');return false;", Visible = (previewState == 0), Tooltip = GetString("preview.tooltip") }; headerActions.ActionsList.Add(preview); headerActions.ActionPerformed += (sender, e) => { if (e.CommandName == ComponentEvents.SAVE) { Save(); } }; }
protected override void OnPreRender(EventArgs e) { string dataCodeName = string.IsNullOrEmpty(ManageDataCodeName) ? QueryHelper.GetString("dataCodeName", string.Empty) : ManageDataCodeName; string deleteDialogUrl = ResolveUrl("~/CMSModules/Reporting/WebAnalytics/Analytics_ManageData.aspx"); deleteDialogUrl = URLHelper.AddParameterToUrl(deleteDialogUrl, "statcodename", URLHelper.URLEncode(dataCodeName)); deleteDialogUrl = URLHelper.AddParameterToUrl(deleteDialogUrl, "hash", QueryHelper.GetHash(deleteDialogUrl)); string deleteScript = string.Format("modalDialog('{0}','AnalyticsManageData',{1},{2});", deleteDialogUrl, 680, 350); string printDialogUrl = string.Format("{0}?reportname={1}¶meters={2}", ResolveUrl(PrintPageURL), ReportName, AnalyticsHelper.GetQueryStringParameters(ReportParameters)); string printScript = string.Format("myModalDialog('{0}&UILang={1}&hash={2}','PrintReport {3}',800,700);return false", printDialogUrl, CultureInfo.CurrentUICulture.IetfLanguageTag, QueryHelper.GetHash(printDialogUrl), ReportName); string subscriptionScript = String.Format("modalDialog('{0}?reportname={1}¶meters={2}&interval={3}','Subscription',{4},{5});return false", ResolveUrl("~/CMSModules/Reporting/Dialogs/EditSubscription.aspx"), ReportName, AnalyticsHelper.GetQueryStringParameters(ReportParameters), HitsIntervalEnumFunctions.HitsConversionToString(SelectedInterval), AnalyticsHelper.SUBSCRIPTION_WINDOW_WIDTH, AnalyticsHelper.SUBSCRIPTION_WINDOW_HEIGHT); string refreshScript = "function RefreshPage() {" + ControlsHelper.GetPostBackEventReference(this, "") + "};"; ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "RefreshScript", ScriptHelper.GetScript(refreshScript)); // Register special script for print window ScriptHelper.RegisterPrintDialogScript(Page); ScriptHelper.RegisterDialogScript(Page); headerActions.PanelCssClass = PanelCssClass; // Create header actions SaveAction save = new SaveAction(Page); headerActions.ActionsList.Add(save); // Print HeaderAction print = new HeaderAction { Text = GetString("Analytics_Report.Print"), OnClientClick = printScript, Enabled = PrintEnabled, ButtonStyle = ButtonStyle.Default, }; headerActions.ActionsList.Add(print); var cui = MembershipContext.AuthenticatedUser; // Manage data if (cui.IsAuthorizedPerResource("CMS.WebAnalytics", "ManageData") && DisplayManageData) { HeaderAction delete = new HeaderAction { Text = GetString("Analytics_Report.ManageData"), OnClientClick = deleteScript, ButtonStyle = ButtonStyle.Default, }; headerActions.ActionsList.Add(delete); } // Report subscription enabled test GeneralizedInfo ri = BaseAbstractInfoProvider.GetInfoByName(PredefinedObjectType.REPORT, ReportName); if (ri != null) { bool enableSubscription = ValidationHelper.GetBoolean(ri.GetValue("ReportEnableSubscription"), true); // Show enable subscription only for users with subscribe or modify. enableSubscription &= (cui.IsAuthorizedPerResource("cms.reporting", "subscribe") || cui.IsAuthorizedPerResource("cms.reporting", "modify")); if (enableSubscription) { // Subscription HeaderAction subscription = new HeaderAction { Text = GetString("notifications.subscribe"), OnClientClick = subscriptionScript, ButtonStyle = ButtonStyle.Default, }; headerActions.ActionsList.Add(subscription); } } base.OnPreRender(e); }
private void ReloadMenu() { if (StopProcessing) { return; } bool displayObjectMenu = false; BaseInfo editInfo = InfoObject ?? ModuleManager.GetReadOnlyObject(ObjectManager.ObjectType); if (editInfo != null) { // Do not display items when object does not support locking and when there is no associated UIForm displayObjectMenu = editInfo.TypeInfo.SupportsLocking && ObjectManager.ShowPanel; } if (displayObjectMenu) { // Handle several reloads menu.ActionsList.Clear(); ClearProperties(); if (!HideStandardButtons) { // Handle save action if (ShowSave) { save = new SaveAction { Tooltip = ResHelper.GetString("EditMenu.Save", ResourceCulture), Enabled = AllowSave, EventName = "", CommandName = "", Index = -2 }; if (AllowSave) { string script = RaiseGetClientActionScript(ComponentEvents.SAVE); script += RaiseGetClientValidationScript(ComponentEvents.SAVE, ObjectManager.GetJSFunction(ComponentEvents.SAVE, null, null)); save.OnClientClick = script; } AddAction(save); } // Object update if (SynchronizationHelper.UseCheckinCheckout && (ObjectManager.Mode == FormModeEnum.Update)) { if (InfoObject != null) { if (ShowCheckOut) { checkout = new HeaderAction { Tooltip = ResHelper.GetString("ObjectEditMenu.Checkout", ResourceCulture), Text = ResHelper.GetString("EditMenu.IconCheckout", ResourceCulture), Enabled = AllowCheckOut }; if (AllowCheckOut) { string script = RaiseGetClientActionScript(ComponentEvents.CHECKOUT); script += RaiseGetClientValidationScript(ComponentEvents.CHECKOUT, ObjectManager.GetJSFunction(ComponentEvents.CHECKOUT, null, null)); checkout.OnClientClick = script; } AddAction(checkout); } if (ShowUndoCheckOut) { undocheckout = new HeaderAction { Tooltip = ResHelper.GetString("ObjectEditMenu.UndoCheckOut", ResourceCulture), Text = ResHelper.GetString("EditMenu.IconUndoCheckout", ResourceCulture), Enabled = AllowUndoCheckOut }; if (AllowUndoCheckOut) { string script = RaiseGetClientActionScript(ComponentEvents.UNDO_CHECKOUT); script += RaiseGetClientValidationScript(ComponentEvents.UNDO_CHECKOUT, ObjectManager.GetJSFunction(ComponentEvents.UNDO_CHECKOUT, null, null)); undocheckout.OnClientClick = script; } AddAction(undocheckout); } if (ShowCheckIn) { checkin = new HeaderAction { Tooltip = ResHelper.GetString("ObjectEditMenu.Checkin", ResourceCulture), Text = ResHelper.GetString("EditMenu.IconCheckin", ResourceCulture), Enabled = AllowCheckIn }; if (AllowCheckIn) { string script = RaiseGetClientActionScript(ComponentEvents.CHECKIN); script += RaiseGetClientValidationScript(ComponentEvents.CHECKIN, ObjectManager.GetJSFunction(ComponentEvents.CHECKIN, null, null)); checkin.OnClientClick = script; } if (ShowCheckInWithComment) { AddCommentAction(ComponentEvents.CHECKIN, checkin); } else { AddAction(checkin); } } } } } } // Add extra actions if (ObjectManager.ShowPanel && (mExtraActions != null)) { foreach (HeaderAction action in mExtraActions) { AddAction(action); } } }
/// <summary> /// Creates buttons in header actions /// </summary> private void CreateButtons() { bool allowed = CheckModifyPermissions(false); var processAction = new HeaderAction { ButtonStyle = ButtonStyle.Default, CommandName = PROCESS_ACTION, OnClientClick = "if (!confirm(" + ScriptHelper.GetString(GetString("translationservice.confirmprocesstranslations")) + ")) { return false; }", Tooltip = GetString("translationservice.importtranslationstooltip"), Text = GetString("translationservice.importtranslations"), Enabled = allowed && ((SubmissionInfo.SubmissionStatus == TranslationStatusEnum.TranslationReady) || (SubmissionInfo.SubmissionStatus == TranslationStatusEnum.TranslationCompleted) || (SubmissionInfo.SubmissionStatus == TranslationStatusEnum.ProcessingError)) }; var resubmitAction = new HeaderAction { ButtonStyle = ButtonStyle.Default, CommandName = RESUBMIT_ACTION, Tooltip = GetString("translationservice.resubmittooltip"), Text = GetString("translationservice.resubmit"), Enabled = allowed && ((SubmissionInfo.SubmissionStatus == TranslationStatusEnum.WaitingForTranslation) || (SubmissionInfo.SubmissionStatus == TranslationStatusEnum.SubmissionError)) }; var updateAction = new HeaderAction { ButtonStyle = ButtonStyle.Default, CommandName = "updateandresubmit", Tooltip = GetString("translationservice.updateandresubmittooltip"), Text = GetString("translationservice.updateandresubmit"), Enabled = allowed && ((SubmissionInfo.SubmissionStatus == TranslationStatusEnum.WaitingForTranslation) || (SubmissionInfo.SubmissionStatus == TranslationStatusEnum.SubmissionError)) }; var saveAction = new SaveAction(Page); saveAction.Enabled = allowed; var actions = HeaderActions.ActionsList; actions.AddRange(new[] { saveAction, updateAction, resubmitAction, processAction }); // Check if current service supports canceling var service = TranslationServiceInfoProvider.GetTranslationServiceInfo(SubmissionInfo.SubmissionServiceID); if (service != null) { bool serviceSupportsCancel = service.TranslationServiceSupportsCancel; var cancelAction = new HeaderAction { ButtonStyle = ButtonStyle.Default, CommandName = "cancel", Tooltip = serviceSupportsCancel ? GetString("translationservice.cancelsubmissiontooltip") : String.Format(GetString("translationservice.cancelnotsupported"), service.TranslationServiceDisplayName), Text = GetString("translationservice.cancelsubmission"), Enabled = allowed && (SubmissionInfo.SubmissionStatus == TranslationStatusEnum.WaitingForTranslation) && serviceSupportsCancel }; actions.Add(cancelAction); } HeaderActions.ReloadData(); }
/// <summary> /// Initializes header actions. /// </summary> protected void InitHeaderActions() { menu.ActionsList.Clear(); // Add save action save = new SaveAction(); menu.ActionsList.Add(save); bool isAuthorized = CurrentUser.IsAuthorizedPerResource("cms.form", "EditForm") && (EditedObject != null); int attachCount = 0; if (isAuthorized) { // Get number of attachments InfoDataSet<MetaFileInfo> ds = MetaFileInfoProvider.GetMetaFiles(formInfo.FormID, BizFormInfo.OBJECT_TYPE, ObjectAttachmentsCategories.FORMLAYOUT, null, null, "MetafileID", -1); attachCount = ds.Items.Count; // Register attachments count update module ScriptHelper.RegisterModule(this, "CMS/AttachmentsCountUpdater", new { Selector = "." + mAttachmentsActionClass, Text = ResHelper.GetString("general.attachments") }); // Register dialog scripts ScriptHelper.RegisterDialogScript(Page); } // Prepare metafile dialog URL string metaFileDialogUrl = ResolveUrl(@"~/CMSModules/AdminControls/Controls/MetaFiles/MetaFileDialog.aspx"); string query = string.Format("?objectid={0}&objecttype={1}", formInfo.FormID, BizFormInfo.OBJECT_TYPE); metaFileDialogUrl += string.Format("{0}&category={1}&hash={2}", query, ObjectAttachmentsCategories.FORMLAYOUT, QueryHelper.GetHash(query)); // Init attachment button attachments = new HeaderAction { Text = GetString("general.attachments") + ((attachCount > 0) ? " (" + attachCount + ")" : string.Empty), Tooltip = GetString("general.attachments"), OnClientClick = string.Format(@"if (modalDialog) {{modalDialog('{0}', 'Attachments', '700', '500');}}", metaFileDialogUrl) + " return false;", Enabled = isAuthorized, CssClass = mAttachmentsActionClass, ButtonStyle = ButtonStyle.Default, }; menu.ActionsList.Add(attachments); }