예제 #1
0
        private async Task DefaultValues_List_ListSearch(ComponentListSearchEventArgs e)
        {
            if (!wim.IsSearchListMode)
            {
                var idQueryString = Request.Query["item"].ToString();

                int.TryParse(idQueryString, out int id);

                var mailTemplate = await _mailTemplateRepository.FetchSingleAsync(id);

                var list = await _defaultValuePlaceholderRepository.FetchAllByMailTemplateAsync(mailTemplate.Identifier);

                var subjectPlaceholders = Logic.PlaceholderLogic.GetPlaceholderTags(mailTemplate.Subject);
                var bodyPlaceholders    = Logic.PlaceholderLogic.GetPlaceholderTags(mailTemplate.Body);

                var tmpID = -1;

                list.AddRange(subjectPlaceholders.Where(x => list.All(defaultValue => defaultValue.Placeholder != x)).Select(x => new Data.DefaultValuePlaceholder {
                    Placeholder = x, ID = tmpID--
                }));
                list.AddRange(bodyPlaceholders.Where(x => list.All(defaultValue => defaultValue.Placeholder != x)).Select(x => new Data.DefaultValuePlaceholder {
                    Placeholder = x, ID = tmpID--
                }));

                wim.SearchResultItemPassthroughParameterProperty = nameof(Data.DefaultValuePlaceholder.ID);

                wim.ListDataColumns.Add(new ListDataColumn("ID", nameof(Data.DefaultValuePlaceholder.ID), ListDataColumnType.UniqueHighlightedIdentifier));
                wim.ListDataColumns.Add(new ListDataColumn("Placeholder", nameof(Data.DefaultValuePlaceholder.Placeholder)));
                wim.ListDataColumns.Add(new ListDataColumn("Value", nameof(Data.DefaultValuePlaceholder.Value))
                {
                    Alignment         = Align.Left,
                    Type              = ListDataColumnType.Default,
                    EditConfiguration = new ListDataEditConfiguration()
                    {
                        Type          = ListDataEditConfigurationType.TextField,
                        PropertyToSet = nameof(Data.DefaultValuePlaceholder.Value),
                        Width         = 580
                    },
                });

                wim.SearchListCanClickThrough = false;
                wim.ListDataAdd(list);
            }
        }
예제 #2
0
        private async Task MailTemplatesList_ListLoad(ComponentListEventArgs e)
        {
            Implement = await _mailTemplateRepository.FetchSingleAsync(e.SelectedKey);

            if (Implement != null)
            {
                var latestTemplate = await _mailTemplateListRepository.FetchSingleByIdentifierAsync(Implement.Identifier);

                if (latestTemplate != null && Implement.ID != latestTemplate.ID)
                {
                    // someone is using the url to go to an old template, redirect to newest
                    Response.Redirect(wim.GetUrl(new KeyValue[] {
                        new KeyValue {
                            Key = "list", Value = wim.CurrentList.ID
                        },
                        new KeyValue {
                            Key = "item", Value = latestTemplate.ID
                        }
                    }));
                }

                if (e.SelectedKey > 0)
                {
                    ListOfAvailablePlaceholders  = "<b>Subject:</b><br/>";
                    ListOfAvailablePlaceholders += string.Join("<br/>", Logic.PlaceholderLogic.GetPlaceholderTags(Implement.Subject));
                    ListOfAvailablePlaceholders += "<br/><br/><b>Body:</b><br/>";
                    ListOfAvailablePlaceholders += string.Join("<br/>", Logic.PlaceholderLogic.GetPlaceholderTags(Implement.Body));
                }
            }
            else
            {
                Implement = new Data.MailTemplate();
            }

            // only show option to revert if there is a published version, a.k.a. a major version
            wim.SetPropertyVisibility(nameof(BtnRevert), Implement.VersionMinor > 0 && Implement.VersionMajor > 0);
            // only show publish button if current version is not published
            wim.SetPropertyVisibility(nameof(BtnPublish), !(Implement.IsPublished.HasValue && Implement.IsPublished.Value));
            wim.SetPropertyVisibility(nameof(BtnPreview), !wim.IsEditMode);
            wim.SetPropertyVisibility(nameof(BtnSendTestMail), !wim.IsEditMode);
            //wim.SetPropertyVisibility(nameof(BtnDefaultValues), !wim.IsEditMode);
            // not working yet, so invisible
            wim.SetPropertyVisibility(nameof(BtnDefaultValues), false);


            Utility.ReflectProperty(Implement, this);
        }