@*   Xafari Framework version : 17.2.3011.1336   *@

@using DevExpress.ExpressApp.Editors
@using Xafari.Mvc.MVCx.Extensions
@using Xafari.Mvc.Request
@using Xafari.Mvc.Templates

@model Xafari.Mvc.Editors.MvcObjectPropertyEditorBase

@{
	// Init StyleAttribute
	var styleValue = string.Empty;
	var appearanceFormat = this.Model as IAppearanceFormat;
	if (appearanceFormat != null) { styleValue = appearanceFormat.GetStyleAttributeValue(); }

	var styleAttribute = string.Empty;
	if (!string.IsNullOrEmpty(styleValue)) { styleAttribute = string.Format("style = {0}", styleValue); }
	//

	if (this.Model.PropertyValue == null)
	{
		<div class="WebEditorCell" @(styleAttribute)>
			<a href="javascript:;">@this.Model.GetPropertyDisplayValue()</a>
		</div>
	}
	else
	{
		if (this.Model.CanShowLink())
		{
			var currentFrame = MvcApplication.Instance.GetViewItem(this.ViewData.Frame(), this.Model.Id) != null ? this.ViewData.Frame() : this.ViewData.Window();
            var view = MvcApplication.Instance.GetView(currentFrame);
			var mvcActionUrl = this.Url.Action("NavigateTo", "MvcObjectPropertyEditor", new
			{
				viewId = view.ViewId(),
				editorId = this.Model.Id,
				objectId = this.Model.GetKeyObjectAsString(),
				windowId = this.ViewData.Window().WindowId(),
				windowState = ClientRequest.Current.Window.WindowState

			});
			var actionExecuteScript = this.Model.NavigateToObjectAction.GetXafActionExecuteScript(this.ViewData.Window(), this.Model.NavigateToObjectAction.ConfirmationMessage, mvcActionUrl);

			<div class="WebEditorCell" @(styleAttribute)>
				<a onclick="@(actionExecuteScript) window.disableNotifyWindowClose = true; event.cancelBubble = true; return false;" href="javascript:;">@(this.Model.GetPropertyDisplayValue())</a>
			</div>
		}
		else
		{
			<div class="WebEditorCell" @(styleAttribute)>
				<span>@this.Model.GetPropertyDisplayValue()</span>
			</div>
		}
	}
}
