示例#1
0
        private static HElement Page(MainState state)
        {
            var page = h.Html
                       (
                h.Head(
                    h.Element("title", "NitroBolt.Wui - WebExample. State machine"),
                    h.Css
                    (
                        @"
              .section {min-height:100px;border:1px solid lightgray;margin-bottom:2px;}
              .header {background-color:#E0E0FF;}
            "
                    )
                    ),
                h.Body
                (
                    h.Div
                    (
                        h.@class("section"),
                        h.Div(h.@class("header"), "Клиентский интерфейс"),
                        h.Div
                        (
                            h.data("name", "order"), h.data("id", state.Orders.Count),
                            h.Div("Новый заказ"),
                            h.Div("Опции"),
                            h.Span("\xA0▪ "), h.Span("На указанное время: "),
                            h.Input(h.type("text"), h.data("name", "to-time")), h.Span(h.style("color:darkgray;"), $" Пример(+15с): {DateTime.Now.AddSeconds(15)}"),
                            h.Br(),
                            h.Span("\xA0▪ "), h.Input(h.type("checkbox"), h.data("name", "is-delivery")), h.Span("Доставка"), h.Br(),
                            new[] { "A", "B" }
                            .Select(order =>
                                    h.Input(h.type("button"), new hdata {
                { "command", "new-order" }, { "container", "order" }, { "name", order }
            }, h.value("Сделать заказ типа " + order), h.onclick(";"))
                                    )
                        ),
                        h.Div
                        (
                            h.Div("Заказы"),
                            state.Orders.Where(order => order.Status != OrderStatus.ToTable && order.Status != OrderStatus.Deliveried).Select(order =>
                                                                                                                                              h.Div
                                                                                                                                              (
                                                                                                                                                  h.Span(order.Title), ViewStatus(order.Status), order.Status == OrderStatus.InQueue ? h.Span(string.Format(" Отложен до {0:dd.MM.yy HH:mm}", order.ToTime)): null,
                                                                                                                                                  order.IsDelivery ? h.Span(h.title("Доставка"), " => "):null//,

                                                                                                                                              ))
                        )
                    ),
                    h.Div
                    (
                        h.@class("section"),
                        h.Div(h.@class("header"), "Производственный интерфейс"),
                        state.Orders.Where(order => order.Status == OrderStatus.New || order.Status == OrderStatus.Prepare && !order.IsReady).Select(order =>
                                                                                                                                                     h.Div
                                                                                                                                                     (
                                                                                                                                                         h.Div(h.Span("Заказ: "), h.Span(order.Title), ViewStatus(order.Status)),
                                                                                                                                                         order.Products.Select(product =>
                                                                                                                                                                               h.Div
                                                                                                                                                                               (
                                                                                                                                                                                   h.style("padding-left:15px;"),
                                                                                                                                                                                   h.Span("Продукт " + product.Name), ViewStatus(product.Status),
                                                                                                                                                                                   product.Status == ProductStatus.New || product.Status == ProductStatus.Prepare
                     ? h.Input(h.type("button"), new hdata {
                { "command", product.Status == ProductStatus.New ? "product-prepare" : "product-ready" }, { "order", order.Id }, { "product", product.Id }
            }, product.Status == ProductStatus.New ? h.value("Приготовить") : h.value("Готово"), h.onclick(";"))
                     : null
                                                                                                                                                                               )
                                                                                                                                                                               )
                                                                                                                                                     )

                                                                                                                                                     )
                    ),
                    h.Div
                    (
                        h.@class("section"),
                        h.Div(h.@class("header"), "Интерфейс сборщика"),
                        state.Orders.Where(order => order.IsReady).Select(order =>
                                                                          h.Div
                                                                          (
                                                                              h.Span(order.Title),
                                                                              h.Span(" "),
                                                                              h.Input(h.type("button"), new hdata {
                { "command", "order-build" }, { "order", order.Id }
            }, h.value("Собрать"), h.onclick(";"))
                                                                          )

                                                                          )
                    ),
                    h.Div
                    (
                        h.@class("section"),
                        h.Div(h.@class("header"), "Интерфейс официанта"),
                        state.Orders.Where(order => order.Status == OrderStatus.Ready && !order.IsDelivery).Select(order =>
                                                                                                                   h.Div
                                                                                                                   (
                                                                                                                       h.Span(order.Title),
                                                                                                                       h.Span(" "),
                                                                                                                       h.Input(h.type("button"), new hdata {
                { "command", "order-to-table" }, { "order", order.Id }
            }, h.value("Передать клиенту"), h.onclick(";"))
                                                                                                                   )

                                                                                                                   )
                    ),
                    h.Div
                    (
                        h.@class("section"),
                        h.Div(h.@class("header"), "Назначить курьера"),
                        state.Orders.Where(order => order.Status == OrderStatus.Ready && order.IsDelivery).Select(order =>
                                                                                                                  h.Div
                                                                                                                  (
                                                                                                                      h.Span(order.Title),
                                                                                                                      h.Span(" "),
                                                                                                                      new[] { "Иванов П.", "Петров Д.", "Сидоров К." }
                                                                                                                      .Select(courier =>
                                                                                                                              h.Input(h.type("button"), new hdata {
                { "command", "courier" }, { "order", order.Id }, { "courier", courier }
            }, h.value(courier), h.onclick(";"))
                                                                                                                              )
                                                                                                                  )

                                                                                                                  )
                    ),
                    h.Div
                    (
                        h.@class("section"),
                        h.Div(h.@class("header"), "Интерфейс курьера"),
                        state.Orders.Where(order => order.Status == OrderStatus.ToDelivery).Select(order =>
                                                                                                   h.Div
                                                                                                   (
                                                                                                       h.Span(order.Title),
                                                                                                       h.Span(" "),
                                                                                                       h.Input(h.type("button"), new hdata {
                { "command", "order-deliveried" }, { "order", order.Id }
            }, h.value("Передать клиенту"), h.onclick(";"))
                                                                                                   )

                                                                                                   )
                    ),
                    h.Div
                    (
                        h.@class("section"),
                        h.Div(h.@class("header"), "Выполненные заказы"),
                        state.Orders.Where(order => order.Status == OrderStatus.ToTable || order.Status == OrderStatus.Deliveried).Select(order =>
                                                                                                                                          h.Div
                                                                                                                                          (
                                                                                                                                              h.Span(order.Title)
                                                                                                                                          )

                                                                                                                                          )
                    )

                )
                       );

            return(page);
        }
示例#2
0
    private static HElement Page(MainState state)
    {
      var page = h.Html
      (
        h.Head(
          h.Element("title", "NitroBolt.Wui - WebExample. State machine"),
          h.Css
          (
            @"
              .section {min-height:100px;border:1px solid lightgray;margin-bottom:2px;}
              .header {background-color:#E0E0FF;}
            "
          )
        ),
        h.Body
        (
           h.Div
           (
             h.@class("section"),
             h.Div(h.@class("header"), "Клиентский интерфейс"),
             h.Div
             (
               h.data("name", "order"), h.data("id", state.Orders.Count),
               h.Div("Новый заказ"),
               h.Div("Опции"),
               h.Span("\xA0▪ "), h.Span("На указанное время: "),
               h.Input(h.type("text"), h.data("name", "to-time")), h.Span(h.style("color:darkgray;"),  $" Пример(+15с): {DateTime.Now.AddSeconds(15)}"),
               h.Br(),
               h.Span("\xA0▪ "), h.Input(h.type("checkbox"), h.data("name", "is-delivery")), h.Span("Доставка"), h.Br(),
               new[] { "A", "B"}
                .Select(order => 
                  h.Input(h.type("button"), new hdata { { "command", "new-order" }, { "container", "order"}, {"name", order} }, h.value("Сделать заказ типа " + order), h.onclick(";"))
                )
             ),
             h.Div
             (
               h.Div("Заказы"),
               state.Orders.Where(order => order.Status != OrderStatus.ToTable && order.Status != OrderStatus.Deliveried).Select(order => 
                 h.Div
                 (
                   h.Span(order.Title), ViewStatus(order.Status), order.Status == OrderStatus.InQueue ? h.Span(string.Format(" Отложен до {0:dd.MM.yy HH:mm}", order.ToTime)): null,
                   order.IsDelivery ? h.Span(h.title("Доставка"), " => "):null//,

                 ))
             )
           ),
           h.Div
           (
             h.@class("section"),
             h.Div(h.@class("header"), "Производственный интерфейс"),
             state.Orders.Where(order => order.Status == OrderStatus.New || order.Status == OrderStatus.Prepare && !order.IsReady).Select(order => 
               h.Div
               (
                 h.Div(h.Span("Заказ: "), h.Span(order.Title), ViewStatus(order.Status)), 
                 order.Products.Select(product =>
                   h.Div
                   (
                     h.style("padding-left:15px;"),
                     h.Span("Продукт " + product.Name), ViewStatus(product.Status), 
                     product.Status == ProductStatus.New || product.Status == ProductStatus.Prepare
                     ? h.Input(h.type("button"), new hdata{{"command", product.Status == ProductStatus.New ? "product-prepare" : "product-ready"}, {"order", order.Id}, {"product", product.Id}}, product.Status == ProductStatus.New ? h.value("Приготовить") : h.value("Готово"), h.onclick(";"))
                     : null
                   )
                 )
               )
                 
             )
           ),
           h.Div
           (
             h.@class("section"),
             h.Div(h.@class("header"), "Интерфейс сборщика"),
             state.Orders.Where(order => order.IsReady).Select(order => 
               h.Div
               (
                 h.Span(order.Title), 
                 h.Span(" "),
                 h.Input(h.type("button"), new hdata{{"command", "order-build"}, {"order", order.Id}}, h.value("Собрать"), h.onclick(";"))
               )
                 
             )
           ),
           h.Div
           (
             h.@class("section"),
             h.Div(h.@class("header"), "Интерфейс официанта"),
             state.Orders.Where(order => order.Status == OrderStatus.Ready && !order.IsDelivery).Select(order =>
               h.Div
               (
                 h.Span(order.Title),
                 h.Span(" "),
                 h.Input(h.type("button"), new hdata { { "command", "order-to-table" }, { "order", order.Id } }, h.value("Передать клиенту"), h.onclick(";"))
               )

             )
           ),
           h.Div
           (
             h.@class("section"),
             h.Div(h.@class("header"), "Назначить курьера"),
             state.Orders.Where(order => order.Status == OrderStatus.Ready && order.IsDelivery).Select(order =>
               h.Div
               (
                 h.Span(order.Title),
                 h.Span(" "),
                 new[] { "Иванов П.", "Петров Д.", "Сидоров К." }
                 .Select(courier =>
                   h.Input(h.type("button"), new hdata { { "command", "courier" }, { "order", order.Id }, {"courier", courier }}, h.value(courier), h.onclick(";"))
                 )
               )

             )
           ),
           h.Div
           (
             h.@class("section"),
             h.Div(h.@class("header"), "Интерфейс курьера"),
             state.Orders.Where(order => order.Status == OrderStatus.ToDelivery).Select(order =>
               h.Div
               (
                 h.Span(order.Title),
                 h.Span(" "),
                 h.Input(h.type("button"), new hdata { { "command", "order-deliveried" }, { "order", order.Id } }, h.value("Передать клиенту"), h.onclick(";"))
               )

             )
           ),
           h.Div
           (
             h.@class("section"),
             h.Div(h.@class("header"), "Выполненные заказы"),
             state.Orders.Where(order => order.Status == OrderStatus.ToTable || order.Status == OrderStatus.Deliveried).Select(order =>
               h.Div
               (
                 h.Span(order.Title)
               )

             )
           )

        )
      );
      return page;
    }